Submission #35145

# Submission time Handle Problem Language Result Execution time Memory
35145 2017-11-18T10:35:16 Z Pajaraja Money (IZhO17_money) C++14
0 / 100
0 ms 9828 KB
#include <bits/stdc++.h>
using namespace std;
int bit[1000007],a[1000007],n;
void upd(int x)
{
	while(x<=n)
	{
		bit[x]++;
		x+=(x&-x);
	}
}
int sum(int x)
{
	int s=0;
	while(x>0)
	{
		s+=bit[x];
		x-=(x&-x);
	}
	return s;
}
bool ima(int l,int r) {return sum(r-1)>sum(l);}
int main()
{
	int cnt=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	upd(a[0]);
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1] || ima(a[i-1],a[i])) cnt++;;
		upd(a[i]);
	}
	printf("%d",cnt);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:26:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
money.cpp:27:40: 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 Correct 0 ms 9828 KB Output is correct
9 Correct 0 ms 9828 KB Output is correct
10 Incorrect 0 ms 9828 KB Output isn't correct
11 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 Correct 0 ms 9828 KB Output is correct
9 Correct 0 ms 9828 KB Output is correct
10 Incorrect 0 ms 9828 KB Output isn't correct
11 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 Correct 0 ms 9828 KB Output is correct
9 Correct 0 ms 9828 KB Output is correct
10 Incorrect 0 ms 9828 KB Output isn't correct
11 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 Correct 0 ms 9828 KB Output is correct
9 Correct 0 ms 9828 KB Output is correct
10 Incorrect 0 ms 9828 KB Output isn't correct
11 Halted 0 ms 0 KB -