답안 #166403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166403 2019-12-02T05:37:53 Z abil Money (IZhO17_money) C++14
100 / 100
276 ms 22956 KB
#include <bits/stdc++.h>
 
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define all(s) s.begin(),s.end()
#define int long long
 
using namespace std;
 
const int N = (1e6 + 12);
const int mod = (1e9 + 7);
const int INF = (1e15 + 9);

int t[N], a[N], n;

void update(int ind){
	for(;ind <= N - 12; ind = ind + (ind & (-ind))){
		t[ind]++;
	}
}

int get(int pos){
	int res = 0;
	for(;pos >= 1; pos = pos - (pos & (-pos))){
		res += t[pos];
	}
	return res;
}

int sum(int l, int r) {
    if(l == r) {
        return 0;
    }
    return get(r - 1) - get(l);
}

main()
{
	int ans = 0;
	cin >> n;
	for(int i = 1;i <= n; i++){
		scanf("%lld", &a[i]);
	}
	int i = 1;
	while(i <= n){
		int j = i + 1;
		ans++;
		while(j <= n && a[j] >= a[j - 1] && sum(a[i], a[j]) == 0){
			j++;
		}
		while(i < j) {
				update(a[i]);
				i++;
		}
	}
	cout << ans;
}

Compilation message

money.cpp:39:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
money.cpp: In function 'int main()':
money.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &a[i]);
   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 488 KB Output is correct
26 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 488 KB Output is correct
26 Correct 2 ms 632 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 4 ms 376 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 4 ms 1784 KB Output is correct
38 Correct 4 ms 1784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 488 KB Output is correct
26 Correct 2 ms 632 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 4 ms 376 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 4 ms 1784 KB Output is correct
38 Correct 4 ms 1784 KB Output is correct
39 Correct 89 ms 7368 KB Output is correct
40 Correct 161 ms 11968 KB Output is correct
41 Correct 77 ms 6008 KB Output is correct
42 Correct 71 ms 5660 KB Output is correct
43 Correct 119 ms 4216 KB Output is correct
44 Correct 198 ms 15088 KB Output is correct
45 Correct 189 ms 15008 KB Output is correct
46 Correct 213 ms 15096 KB Output is correct
47 Correct 169 ms 15096 KB Output is correct
48 Correct 184 ms 15096 KB Output is correct
49 Correct 244 ms 22772 KB Output is correct
50 Correct 220 ms 22776 KB Output is correct
51 Correct 276 ms 22748 KB Output is correct
52 Correct 219 ms 22776 KB Output is correct
53 Correct 224 ms 22956 KB Output is correct
54 Correct 219 ms 22648 KB Output is correct
55 Correct 246 ms 22648 KB Output is correct
56 Correct 250 ms 22744 KB Output is correct
57 Correct 239 ms 22792 KB Output is correct
58 Correct 240 ms 22776 KB Output is correct
59 Correct 245 ms 22848 KB Output is correct
60 Correct 245 ms 22776 KB Output is correct
61 Correct 245 ms 22908 KB Output is correct
62 Correct 241 ms 22760 KB Output is correct