답안 #37386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37386 2017-12-25T03:43:40 Z HardNut 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() {
    freopen("money.in", "r", stdin);
    freopen("money.out", "w", stdout);
	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]) > 0) {
			++ans;
			while(last < i) update(a[last++]);
		}
	}
	printf("%d", ans);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:13:36: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("money.in", "r", stdin);
                                    ^
money.cpp:14:38: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("money.out", "w", stdout);
                                      ^
money.cpp:15:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
money.cpp:16: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);
                                             ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 9828 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 9828 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 9828 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 9828 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -