# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
978116 | Isam | Global Warming (CEOI18_glo) | C++17 | 2047 ms | 2908 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
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];
}
for(register int i = ans + 1; i <= n; ++i) if(dp[i] ^ inf) ans = max(ans, i);
}
cout << ans << '\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |