Submission #36474

# Submission time Handle Problem Language Result Execution time Memory
36474 2017-12-09T09:31:34 Z szawinis Money (IZhO17_money) C++14
0 / 100
0 ms 9828 KB
#include <bits/stdc++.h>
using namespace std;
const int MAX = (1e6)+1;
 
int n, ans = 1, a[MAX], f[MAX];
void update(int i) { while(i < MAX) ++f[i], i += i & -i; }
int query(int i) {
	int ret = 0;
	while(i > 0) ret += f[i], i -= i & -i;
	return ret;
}
int main() {
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%d", a+i);
	for(int i = 1, last = 0; i < n; i++) {
		if(a[i] < a[i-1] || query(a[i]-1) - query(a[last])) {
			++ans;
			while(last < i) update(a[last++]);
		}
	}
	printf("%d", ans);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:13:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
money.cpp:14:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < n; i++) scanf("%d", a+i);
                                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 0 ms 9828 KB Output is correct
6 Correct 0 ms 9828 KB Output is correct
7 Correct 0 ms 9828 KB Output is correct
8 Incorrect 0 ms 9828 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 0 ms 9828 KB Output is correct
6 Correct 0 ms 9828 KB Output is correct
7 Correct 0 ms 9828 KB Output is correct
8 Incorrect 0 ms 9828 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 0 ms 9828 KB Output is correct
6 Correct 0 ms 9828 KB Output is correct
7 Correct 0 ms 9828 KB Output is correct
8 Incorrect 0 ms 9828 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 0 ms 9828 KB Output is correct
6 Correct 0 ms 9828 KB Output is correct
7 Correct 0 ms 9828 KB Output is correct
8 Incorrect 0 ms 9828 KB Output isn't correct
9 Halted 0 ms 0 KB -