Submission #1092790

# Submission time Handle Problem Language Result Execution time Memory
1092790 2024-09-25T05:59:45 Z Sunbae Mountains (NOI20_mountains) C++17
22 / 100
185 ms 14652 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 3e5 + 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 1624 KB Output is correct
2 Runtime error 47 ms 14652 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 9040 KB Output is correct
2 Correct 37 ms 9040 KB Output is correct
3 Correct 32 ms 9036 KB Output is correct
4 Correct 30 ms 9052 KB Output is correct
5 Correct 31 ms 9052 KB Output is correct
6 Correct 29 ms 9100 KB Output is correct
7 Correct 31 ms 9008 KB Output is correct
8 Correct 25 ms 9040 KB Output is correct
9 Correct 23 ms 9040 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 9040 KB Output is correct
2 Correct 37 ms 9040 KB Output is correct
3 Correct 32 ms 9036 KB Output is correct
4 Correct 30 ms 9052 KB Output is correct
5 Correct 31 ms 9052 KB Output is correct
6 Correct 29 ms 9100 KB Output is correct
7 Correct 31 ms 9008 KB Output is correct
8 Correct 25 ms 9040 KB Output is correct
9 Correct 23 ms 9040 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 58 ms 9484 KB Output is correct
12 Correct 55 ms 9480 KB Output is correct
13 Correct 61 ms 9276 KB Output is correct
14 Correct 56 ms 9276 KB Output is correct
15 Correct 58 ms 9300 KB Output is correct
16 Correct 57 ms 9408 KB Output is correct
17 Correct 59 ms 9296 KB Output is correct
18 Correct 31 ms 9296 KB Output is correct
19 Correct 33 ms 9296 KB Output is correct
20 Correct 1 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 9040 KB Output is correct
2 Correct 37 ms 9040 KB Output is correct
3 Correct 32 ms 9036 KB Output is correct
4 Correct 30 ms 9052 KB Output is correct
5 Correct 31 ms 9052 KB Output is correct
6 Correct 29 ms 9100 KB Output is correct
7 Correct 31 ms 9008 KB Output is correct
8 Correct 25 ms 9040 KB Output is correct
9 Correct 23 ms 9040 KB Output is correct
10 Correct 1 ms 1624 KB Output is correct
11 Correct 58 ms 9484 KB Output is correct
12 Correct 55 ms 9480 KB Output is correct
13 Correct 61 ms 9276 KB Output is correct
14 Correct 56 ms 9276 KB Output is correct
15 Correct 58 ms 9300 KB Output is correct
16 Correct 57 ms 9408 KB Output is correct
17 Correct 59 ms 9296 KB Output is correct
18 Correct 31 ms 9296 KB Output is correct
19 Correct 33 ms 9296 KB Output is correct
20 Correct 1 ms 1628 KB Output is correct
21 Correct 185 ms 9972 KB Output is correct
22 Correct 169 ms 10068 KB Output is correct
23 Correct 172 ms 10064 KB Output is correct
24 Correct 182 ms 10064 KB Output is correct
25 Correct 176 ms 10064 KB Output is correct
26 Correct 170 ms 9976 KB Output is correct
27 Correct 171 ms 10164 KB Output is correct
28 Correct 61 ms 10068 KB Output is correct
29 Correct 61 ms 10172 KB Output is correct
30 Correct 1 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Runtime error 47 ms 14652 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -