Submission #848149

# Submission time Handle Problem Language Result Execution time Memory
848149 2023-09-11T12:46:59 Z KN200711 Global Warming (CEOI18_glo) C++14
100 / 100
40 ms 4064 KB
# include <bits/stdc++.h>
using namespace std;

int main() {
	int N, d;
	scanf("%d %d", &N, &d);
	vector<int> arr(N);
	for(int i=0;i<N;i++) scanf("%d", &arr[i]);
	
	vector<int> wo, wi;
	wo.clear();
	wi.clear();
	
	for(int i=0;i<N;i++) {
		if(wo.size() == 0 || wo.back() < arr[i]) wo.push_back(arr[i]);
		else {
			int c = lower_bound(wo.begin(), wo.end(), arr[i]) - wo.begin();
			wo[c] = arr[i];
		}
		if(wi.size() == 0 || wi.back() < arr[i] - d) {
			wi.push_back(arr[i] - d);
			int p = wi.size();
			wo[p - 1] = min(wo[p-1], wi[p-1]);
		}
		else {
			int c = lower_bound(wi.begin(), wi.end(), arr[i] - d) - wi.begin();
			wi[c] = arr[i] - d;
			wo[c] = min(wo[c], wi[c]);
		}
	}
	printf("%d\n", wo.size());
	return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:31:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   31 |  printf("%d\n", wo.size());
      |          ~^     ~~~~~~~~~
      |           |            |
      |           int          std::vector<int>::size_type {aka long unsigned int}
      |          %ld
glo.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d %d", &N, &d);
      |  ~~~~~^~~~~~~~~~~~~~~~~
glo.cpp:8:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  for(int i=0;i<N;i++) scanf("%d", &arr[i]);
      |                       ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 436 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 436 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 3000 KB Output is correct
2 Correct 40 ms 3152 KB Output is correct
3 Correct 36 ms 3004 KB Output is correct
4 Correct 37 ms 3164 KB Output is correct
5 Correct 19 ms 3540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1112 KB Output is correct
2 Correct 9 ms 1008 KB Output is correct
3 Correct 10 ms 1176 KB Output is correct
4 Correct 5 ms 1196 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 5 ms 1112 KB Output is correct
7 Correct 7 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1880 KB Output is correct
2 Correct 17 ms 1628 KB Output is correct
3 Correct 36 ms 3148 KB Output is correct
4 Correct 18 ms 3252 KB Output is correct
5 Correct 11 ms 2008 KB Output is correct
6 Correct 17 ms 3276 KB Output is correct
7 Correct 18 ms 3792 KB Output is correct
8 Correct 15 ms 1816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 436 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 436 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 36 ms 3000 KB Output is correct
28 Correct 40 ms 3152 KB Output is correct
29 Correct 36 ms 3004 KB Output is correct
30 Correct 37 ms 3164 KB Output is correct
31 Correct 19 ms 3540 KB Output is correct
32 Correct 12 ms 1112 KB Output is correct
33 Correct 9 ms 1008 KB Output is correct
34 Correct 10 ms 1176 KB Output is correct
35 Correct 5 ms 1196 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 5 ms 1112 KB Output is correct
38 Correct 7 ms 1116 KB Output is correct
39 Correct 17 ms 1880 KB Output is correct
40 Correct 17 ms 1628 KB Output is correct
41 Correct 36 ms 3148 KB Output is correct
42 Correct 18 ms 3252 KB Output is correct
43 Correct 11 ms 2008 KB Output is correct
44 Correct 17 ms 3276 KB Output is correct
45 Correct 18 ms 3792 KB Output is correct
46 Correct 15 ms 1816 KB Output is correct
47 Correct 18 ms 1720 KB Output is correct
48 Correct 18 ms 1628 KB Output is correct
49 Correct 37 ms 2908 KB Output is correct
50 Correct 19 ms 3288 KB Output is correct
51 Correct 15 ms 3276 KB Output is correct
52 Correct 19 ms 3276 KB Output is correct
53 Correct 19 ms 3380 KB Output is correct
54 Correct 19 ms 4064 KB Output is correct
55 Correct 30 ms 3164 KB Output is correct