답안 #35146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
35146 2017-11-18T10:45:45 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,last=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1] || ima(a[last],a[i]))
		{
			cnt++;
			while(last<i) upd[a[last++]];
		}
	}
	printf("%d",cnt);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:33:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    while(last<i) upd[a[last++]];
                               ^
money.cpp:33:31: warning: value computed is not used [-Wunused-value]
money.cpp:33:31: warning: value computed is not used [-Wunused-value]
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]);
                                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Incorrect 0 ms 9828 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Incorrect 0 ms 9828 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Incorrect 0 ms 9828 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Incorrect 0 ms 9828 KB Output isn't correct
3 Halted 0 ms 0 KB -