Submission #978127

# Submission time Handle Problem Language Result Execution time Memory
978127 2024-05-08T21:37:22 Z Isam Global Warming (CEOI18_glo) C++17
38 / 100
2000 ms 2776 KB
#include<bits/stdc++.h>
using namespace std;
 
#define eb emplace_back
#define intt long long
#define all(x) begin(x),end(x)
 
 
constexpr int sz = 2e5 + 5;
constexpr intt inf = 1E18 + 7;
 
int n, x, t[sz];
 
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	
	cin >> n >> x;
	
	for(register int i = 1; i <= n; ++i){
		cin >> t[i];
	}
	
	vector<intt> dp(n+1, inf);
		
	dp[0] = -inf;
		
	for(register int i = 1; i <= n; ++i){
			
		int l = upper_bound(all(dp), t[i]) - dp.begin();
		if(dp[l] > t[i] && dp[l-1] < t[i]) dp[l] = t[i];
			
			
	}
	
	int ans(1);
		
	for(register int i = 1; i <= n; ++i) if(dp[i] ^ inf) ans = i;
	
	if(x == 0) return cout << ans << '\n', 0; 
		
	
	for(register int i = n; i >= 1; --i){
		
		t[i] += x;
		
		dp.assign(n+1, inf);
		
		dp[0] = -inf;
		
		for(register int j = 1; j <= n; ++j){
			
			int l = upper_bound(all(dp), t[j]) - dp.begin();
			
			if(dp[l] > t[j] && dp[l-1] < t[j]) dp[l] = t[j];
			
		}
		
		for(register int j = ans; j <= n; ++j) if(dp[j] ^ inf) ans = max(ans, j);
		
		
		
		
		
	}
	
	
	
	
	cout << ans << '\n';
		
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:19:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 |  for(register int i = 1; i <= n; ++i){
      |                   ^
glo.cpp:27:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |  for(register int i = 1; i <= n; ++i){
      |                   ^
glo.cpp:37:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |  for(register int i = 1; i <= n; ++i) if(dp[i] ^ inf) ans = i;
      |                   ^
glo.cpp:42:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   42 |  for(register int i = n; i >= 1; --i){
      |                   ^
glo.cpp:50:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   50 |   for(register int j = 1; j <= n; ++j){
      |                    ^
glo.cpp:58:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   58 |   for(register int j = ans; j <= n; ++j) if(dp[j] ^ inf) ans = max(ans, j);
      |                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 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 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 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 0 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 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 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 0 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 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 18 ms 348 KB Output is correct
20 Correct 16 ms 348 KB Output is correct
21 Correct 17 ms 484 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 16 ms 484 KB Output is correct
24 Correct 16 ms 348 KB Output is correct
25 Correct 18 ms 476 KB Output is correct
26 Correct 21 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2652 KB Output is correct
2 Correct 26 ms 2652 KB Output is correct
3 Correct 26 ms 2776 KB Output is correct
4 Correct 26 ms 2616 KB Output is correct
5 Correct 20 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2091 ms 1624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 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 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 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 0 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 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 18 ms 348 KB Output is correct
20 Correct 16 ms 348 KB Output is correct
21 Correct 17 ms 484 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 16 ms 484 KB Output is correct
24 Correct 16 ms 348 KB Output is correct
25 Correct 18 ms 476 KB Output is correct
26 Correct 21 ms 348 KB Output is correct
27 Correct 26 ms 2652 KB Output is correct
28 Correct 26 ms 2652 KB Output is correct
29 Correct 26 ms 2776 KB Output is correct
30 Correct 26 ms 2616 KB Output is correct
31 Correct 20 ms 2640 KB Output is correct
32 Execution timed out 2061 ms 860 KB Time limit exceeded
33 Halted 0 ms 0 KB -