Submission #1354613
Source Code Expand
#include <bits/stdc++.h> using namespace std; int n; int arr[200100]; int ord[200100]; set<int> s; int main() { int i; long long res = 0; scanf("%d",&n); for (i=0;i<n;i++) scanf("%d",&arr[i]); for (i=0;i<n;i++) ord[arr[i]] = i; s.insert(-1); s.insert(n); for (i=1;i<=n;i++) { res += 1LL*i*((*s.upper_bound(ord[i]))-ord[i])*(ord[i]-(*(--s.lower_bound(ord[i])))); s.insert(ord[i]); } printf("%lld\n",res); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Minimum Sum |
User | tlwpdus |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 500 Byte |
Status | AC |
Exec Time | 135 ms |
Memory | 11264 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:13:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:14:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for (i=0;i<n;i++) scanf("%d",&arr[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0, example1, example2 |
All | corner0, corner1, corner2, corner3, example0, example1, example2, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
corner0 | AC | 116 ms | 11136 KB |
corner1 | AC | 117 ms | 11136 KB |
corner2 | AC | 1 ms | 256 KB |
corner3 | AC | 88 ms | 11136 KB |
example0 | AC | 1 ms | 256 KB |
example1 | AC | 1 ms | 256 KB |
example2 | AC | 1 ms | 256 KB |
maxrand0 | AC | 134 ms | 11136 KB |
maxrand1 | AC | 129 ms | 11264 KB |
maxrand2 | AC | 135 ms | 11136 KB |
rand0 | AC | 1 ms | 256 KB |
rand1 | AC | 1 ms | 256 KB |
rand2 | AC | 1 ms | 256 KB |