Submission #1092789

# Submission time Handle Problem Language Result Execution time Memory
1092789 2024-09-25T05:58:07 Z Sunbae Mountains (NOI20_mountains) C++17
22 / 100
175 ms 15556 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
ll a[N], cp[N], A[N], tot;
int bit[N], m;
void upd(int i){ for(; i<=m; i+=i&-i) ++bit[i];}
int qry(int i){ int r = 0; for(; i; i-=i&-i) r += bit[i]; return r;}
int pos(int x){ return upper_bound(cp, cp+m, x) - cp;}
signed main(){
	int n; scanf("%d", &n);
	for(int i = 1; i<=n; ++i) scanf("%lld", a+i), cp[m++] = a[i];
	sort(cp, cp+m); m = unique(cp, cp+m) - cp;
	for(int i = 1; i<=n; ++i) A[i] = qry(pos(a[i]) - 1), upd(pos(a[i]));
	memset(bit, 0, sizeof(bit));
	for(int i = n; i>=1; --i) A[i] *= qry(pos(a[i]) - 1), upd(pos(a[i]));
	for(int i = 1; i<=n; ++i) tot += A[i];
	printf("%lld", tot);
}

Compilation message

Mountains.cpp: In function 'int main()':
Mountains.cpp:11:14: 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:12:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  for(int i = 1; i<=n; ++i) scanf("%lld", a+i), cp[m++] = a[i];
      |                            ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Runtime error 43 ms 15556 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 9888 KB Output is correct
2 Correct 29 ms 9816 KB Output is correct
3 Correct 36 ms 9812 KB Output is correct
4 Correct 30 ms 9820 KB Output is correct
5 Correct 29 ms 9812 KB Output is correct
6 Correct 29 ms 9832 KB Output is correct
7 Correct 29 ms 9808 KB Output is correct
8 Correct 23 ms 9812 KB Output is correct
9 Correct 23 ms 9808 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 9888 KB Output is correct
2 Correct 29 ms 9816 KB Output is correct
3 Correct 36 ms 9812 KB Output is correct
4 Correct 30 ms 9820 KB Output is correct
5 Correct 29 ms 9812 KB Output is correct
6 Correct 29 ms 9832 KB Output is correct
7 Correct 29 ms 9808 KB Output is correct
8 Correct 23 ms 9812 KB Output is correct
9 Correct 23 ms 9808 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 57 ms 10092 KB Output is correct
12 Correct 57 ms 10068 KB Output is correct
13 Correct 58 ms 10068 KB Output is correct
14 Correct 57 ms 10220 KB Output is correct
15 Correct 55 ms 10080 KB Output is correct
16 Correct 58 ms 10124 KB Output is correct
17 Correct 61 ms 10072 KB Output is correct
18 Correct 32 ms 10288 KB Output is correct
19 Correct 30 ms 10064 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 9888 KB Output is correct
2 Correct 29 ms 9816 KB Output is correct
3 Correct 36 ms 9812 KB Output is correct
4 Correct 30 ms 9820 KB Output is correct
5 Correct 29 ms 9812 KB Output is correct
6 Correct 29 ms 9832 KB Output is correct
7 Correct 29 ms 9808 KB Output is correct
8 Correct 23 ms 9812 KB Output is correct
9 Correct 23 ms 9808 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 57 ms 10092 KB Output is correct
12 Correct 57 ms 10068 KB Output is correct
13 Correct 58 ms 10068 KB Output is correct
14 Correct 57 ms 10220 KB Output is correct
15 Correct 55 ms 10080 KB Output is correct
16 Correct 58 ms 10124 KB Output is correct
17 Correct 61 ms 10072 KB Output is correct
18 Correct 32 ms 10288 KB Output is correct
19 Correct 30 ms 10064 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 173 ms 11060 KB Output is correct
22 Correct 175 ms 11088 KB Output is correct
23 Correct 168 ms 10932 KB Output is correct
24 Correct 169 ms 11088 KB Output is correct
25 Correct 171 ms 10968 KB Output is correct
26 Correct 167 ms 11092 KB Output is correct
27 Correct 167 ms 11060 KB Output is correct
28 Correct 65 ms 11096 KB Output is correct
29 Correct 63 ms 11088 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Runtime error 43 ms 15556 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -