# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
953272 | 2024-03-25T18:53:33 Z | AlphaMale06 | Global Warming (CEOI18_glo) | C++14 | 58 ms | 11100 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N = 2e5+3; vector<int> dp[N]; int ndp[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, d; cin >> n >> d; int a[n]; for(int i=0; i< n; i++)cin >> a[i]; dp[0].pb(2e9+1); int mx=0; for(int i = n-1; i>=0; i--){ if(a[i]<dp[mx].back()){ mx++; dp[mx].pb(a[i]); continue; } int l = 1, r = mx; while(l<=r){ int s = l+r>>1; if(dp[s].back()>=a[i])l=s+1; else r=s-1; } if(dp[l].back()<=a[i])dp[l].pb(a[i]); } int ans=mx; for(int i = 1; i<=n; i++)ndp[i]=1e9+i; ndp[0]=-1e9; int mxx=0; for(int i=0; i < n; i++){ if(a[i]==dp[mx].back()){ dp[mx].pop_back(); if(!dp[mx].size())mx--; } else{ int l = 1, r = mx; while(l<=r){ int s = l+r>>1; if(dp[s].back()>=a[i])l=s+1; else r=s-1; } if(dp[r].size() && dp[r].back()==a[i])dp[r].pop_back(); } int l = 0, r = n; if(a[i]-d>ndp[mxx]){ mxx++; ndp[mxx]=a[i]-d; } else{ while(l<=r){ int s = l+r>>1; if(ndp[s]>a[i]-d)r=s-1; else l=s+1; } ndp[l]=min(ndp[l], a[i]-d); } l=1 , r=mx; while(l<=r){ int s = l+r>>1; if(dp[s].back()>ndp[mxx]){ ans=max(ans, mxx+s); l=s+1; } else{ r=s-1; } } } cout << ans << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 11100 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 11100 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 11100 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 8016 KB | Output is correct |
2 | Correct | 58 ms | 8016 KB | Output is correct |
3 | Correct | 55 ms | 7980 KB | Output is correct |
4 | Correct | 55 ms | 8020 KB | Output is correct |
5 | Incorrect | 31 ms | 9816 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 6232 KB | Output is correct |
2 | Correct | 14 ms | 6236 KB | Output is correct |
3 | Correct | 13 ms | 6236 KB | Output is correct |
4 | Incorrect | 9 ms | 6748 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 6744 KB | Output is correct |
2 | Correct | 26 ms | 6780 KB | Output is correct |
3 | Correct | 56 ms | 8028 KB | Output is correct |
4 | Incorrect | 31 ms | 9820 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 11100 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |