#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define os tree<pair<ll,int>, null_type, less<pair<ll,int>>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 3e5 + 5;
ll A[N], a[N], tot;
signed main(){
int n; scanf("%d", &n);
os s;
for(int i = 0; i<n; ++i){
scanf("%lld", a+i);
A[i] = s.order_of_key(make_pair(a[i], -1));
s.insert(make_pair(a[i], i));
}
s.clear();
for(int i = n-1; i>=0; --i){
tot += A[i] *= s.order_of_key(make_pair(a[i], -1));
s.insert(make_pair(a[i], i));
}
printf("%lld", tot);
}
Compilation message
Mountains.cpp: In function 'int main()':
Mountains.cpp:11:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | int n; scanf("%d", &n);
| ~~~~~^~~~~~~~~~
Mountains.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%lld", a+i);
| ~~~~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
373 ms |
29208 KB |
Output is correct |
3 |
Correct |
360 ms |
29276 KB |
Output is correct |
4 |
Correct |
368 ms |
29264 KB |
Output is correct |
5 |
Correct |
353 ms |
29236 KB |
Output is correct |
6 |
Correct |
354 ms |
29440 KB |
Output is correct |
7 |
Correct |
347 ms |
29232 KB |
Output is correct |
8 |
Correct |
358 ms |
29352 KB |
Output is correct |
9 |
Correct |
355 ms |
29272 KB |
Output is correct |
10 |
Correct |
357 ms |
29264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
193 ms |
24404 KB |
Output is correct |
2 |
Correct |
191 ms |
24400 KB |
Output is correct |
3 |
Correct |
200 ms |
24404 KB |
Output is correct |
4 |
Correct |
195 ms |
24364 KB |
Output is correct |
5 |
Correct |
201 ms |
24652 KB |
Output is correct |
6 |
Correct |
230 ms |
24604 KB |
Output is correct |
7 |
Correct |
192 ms |
24400 KB |
Output is correct |
8 |
Correct |
314 ms |
24400 KB |
Output is correct |
9 |
Correct |
315 ms |
24284 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
193 ms |
24404 KB |
Output is correct |
2 |
Correct |
191 ms |
24400 KB |
Output is correct |
3 |
Correct |
200 ms |
24404 KB |
Output is correct |
4 |
Correct |
195 ms |
24364 KB |
Output is correct |
5 |
Correct |
201 ms |
24652 KB |
Output is correct |
6 |
Correct |
230 ms |
24604 KB |
Output is correct |
7 |
Correct |
192 ms |
24400 KB |
Output is correct |
8 |
Correct |
314 ms |
24400 KB |
Output is correct |
9 |
Correct |
315 ms |
24284 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
358 ms |
24660 KB |
Output is correct |
12 |
Correct |
342 ms |
24748 KB |
Output is correct |
13 |
Correct |
338 ms |
24660 KB |
Output is correct |
14 |
Correct |
352 ms |
24660 KB |
Output is correct |
15 |
Correct |
378 ms |
24748 KB |
Output is correct |
16 |
Correct |
350 ms |
24668 KB |
Output is correct |
17 |
Correct |
338 ms |
24724 KB |
Output is correct |
18 |
Correct |
333 ms |
24988 KB |
Output is correct |
19 |
Correct |
322 ms |
24660 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
448 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
448 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
1372 KB |
Output is correct |
12 |
Correct |
7 ms |
1416 KB |
Output is correct |
13 |
Correct |
7 ms |
1212 KB |
Output is correct |
14 |
Correct |
8 ms |
1396 KB |
Output is correct |
15 |
Correct |
8 ms |
1400 KB |
Output is correct |
16 |
Correct |
7 ms |
1372 KB |
Output is correct |
17 |
Correct |
8 ms |
1372 KB |
Output is correct |
18 |
Correct |
7 ms |
1224 KB |
Output is correct |
19 |
Correct |
7 ms |
1112 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
193 ms |
24404 KB |
Output is correct |
2 |
Correct |
191 ms |
24400 KB |
Output is correct |
3 |
Correct |
200 ms |
24404 KB |
Output is correct |
4 |
Correct |
195 ms |
24364 KB |
Output is correct |
5 |
Correct |
201 ms |
24652 KB |
Output is correct |
6 |
Correct |
230 ms |
24604 KB |
Output is correct |
7 |
Correct |
192 ms |
24400 KB |
Output is correct |
8 |
Correct |
314 ms |
24400 KB |
Output is correct |
9 |
Correct |
315 ms |
24284 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
358 ms |
24660 KB |
Output is correct |
12 |
Correct |
342 ms |
24748 KB |
Output is correct |
13 |
Correct |
338 ms |
24660 KB |
Output is correct |
14 |
Correct |
352 ms |
24660 KB |
Output is correct |
15 |
Correct |
378 ms |
24748 KB |
Output is correct |
16 |
Correct |
350 ms |
24668 KB |
Output is correct |
17 |
Correct |
338 ms |
24724 KB |
Output is correct |
18 |
Correct |
333 ms |
24988 KB |
Output is correct |
19 |
Correct |
322 ms |
24660 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
389 ms |
25428 KB |
Output is correct |
22 |
Correct |
373 ms |
25424 KB |
Output is correct |
23 |
Correct |
375 ms |
25432 KB |
Output is correct |
24 |
Correct |
352 ms |
25424 KB |
Output is correct |
25 |
Correct |
374 ms |
25428 KB |
Output is correct |
26 |
Correct |
362 ms |
25772 KB |
Output is correct |
27 |
Correct |
372 ms |
25628 KB |
Output is correct |
28 |
Correct |
347 ms |
25424 KB |
Output is correct |
29 |
Correct |
354 ms |
25684 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
373 ms |
29208 KB |
Output is correct |
3 |
Correct |
360 ms |
29276 KB |
Output is correct |
4 |
Correct |
368 ms |
29264 KB |
Output is correct |
5 |
Correct |
353 ms |
29236 KB |
Output is correct |
6 |
Correct |
354 ms |
29440 KB |
Output is correct |
7 |
Correct |
347 ms |
29232 KB |
Output is correct |
8 |
Correct |
358 ms |
29352 KB |
Output is correct |
9 |
Correct |
355 ms |
29272 KB |
Output is correct |
10 |
Correct |
357 ms |
29264 KB |
Output is correct |
11 |
Correct |
193 ms |
24404 KB |
Output is correct |
12 |
Correct |
191 ms |
24400 KB |
Output is correct |
13 |
Correct |
200 ms |
24404 KB |
Output is correct |
14 |
Correct |
195 ms |
24364 KB |
Output is correct |
15 |
Correct |
201 ms |
24652 KB |
Output is correct |
16 |
Correct |
230 ms |
24604 KB |
Output is correct |
17 |
Correct |
192 ms |
24400 KB |
Output is correct |
18 |
Correct |
314 ms |
24400 KB |
Output is correct |
19 |
Correct |
315 ms |
24284 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
358 ms |
24660 KB |
Output is correct |
22 |
Correct |
342 ms |
24748 KB |
Output is correct |
23 |
Correct |
338 ms |
24660 KB |
Output is correct |
24 |
Correct |
352 ms |
24660 KB |
Output is correct |
25 |
Correct |
378 ms |
24748 KB |
Output is correct |
26 |
Correct |
350 ms |
24668 KB |
Output is correct |
27 |
Correct |
338 ms |
24724 KB |
Output is correct |
28 |
Correct |
333 ms |
24988 KB |
Output is correct |
29 |
Correct |
322 ms |
24660 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
1 ms |
348 KB |
Output is correct |
38 |
Correct |
1 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
448 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
7 ms |
1372 KB |
Output is correct |
42 |
Correct |
7 ms |
1416 KB |
Output is correct |
43 |
Correct |
7 ms |
1212 KB |
Output is correct |
44 |
Correct |
8 ms |
1396 KB |
Output is correct |
45 |
Correct |
8 ms |
1400 KB |
Output is correct |
46 |
Correct |
7 ms |
1372 KB |
Output is correct |
47 |
Correct |
8 ms |
1372 KB |
Output is correct |
48 |
Correct |
7 ms |
1224 KB |
Output is correct |
49 |
Correct |
7 ms |
1112 KB |
Output is correct |
50 |
Correct |
0 ms |
348 KB |
Output is correct |
51 |
Correct |
389 ms |
25428 KB |
Output is correct |
52 |
Correct |
373 ms |
25424 KB |
Output is correct |
53 |
Correct |
375 ms |
25432 KB |
Output is correct |
54 |
Correct |
352 ms |
25424 KB |
Output is correct |
55 |
Correct |
374 ms |
25428 KB |
Output is correct |
56 |
Correct |
362 ms |
25772 KB |
Output is correct |
57 |
Correct |
372 ms |
25628 KB |
Output is correct |
58 |
Correct |
347 ms |
25424 KB |
Output is correct |
59 |
Correct |
354 ms |
25684 KB |
Output is correct |
60 |
Correct |
0 ms |
348 KB |
Output is correct |
61 |
Correct |
387 ms |
29368 KB |
Output is correct |
62 |
Correct |
399 ms |
29264 KB |
Output is correct |
63 |
Correct |
375 ms |
29256 KB |
Output is correct |
64 |
Correct |
384 ms |
29268 KB |
Output is correct |
65 |
Correct |
421 ms |
29376 KB |
Output is correct |
66 |
Correct |
378 ms |
29208 KB |
Output is correct |
67 |
Correct |
427 ms |
29264 KB |
Output is correct |
68 |
Correct |
365 ms |
29268 KB |
Output is correct |
69 |
Correct |
373 ms |
25684 KB |
Output is correct |
70 |
Correct |
1 ms |
348 KB |
Output is correct |