# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
519765 | 2022-01-27T09:59:18 Z | idas | Global Warming (CEOI18_glo) | C++11 | 61 ms | 4716 KB |
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define f first #define s second #define pb push_back #define sz(x) ((int)((x).size())) #define le(vec) vec[vec.size()-1] #define all(x) (x).begin(), (x).end() #define TSTS int ttt; cin >> ttt; while(ttt--) solve() using namespace std; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; typedef map<int, int> mii; typedef vector<int> vi; typedef long double ld; typedef long long ll; const int INF=1e9, MOD=1e9+7, mod=998244353; const ll LINF=1e18; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int N=2e5+10; int n, x, t[N], d[N]; int main() { setIO(); cin >> n >> x; FOR(i, 0, n) cin >> t[i]; vi lds; for(int i=n-1; i>=0; i--){ int l=0, r=sz(lds); while(l<r){ int m=(l+r)/2; if(lds[m]>t[i]) l=m+1; else r=m; } if(l==sz(lds)) lds.pb(t[i]); else lds[l]=t[i]; d[i]=sz(lds); } vi lis; int mx=0; FOR(i, 0, n) { t[i]-=x; int in=lower_bound(all(lis), t[i])-lis.begin(); if(in==sz(lis)) lis.pb(t[i]); else lis[in]=t[i]; int now=sz(lis)-1; while(now!=-1 && lis[now]>=t[i+1]) now--; if(now!=-1) mx=max(mx, now+1+d[i+1]); } cout << mx; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 61 ms | 3820 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 1228 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 2012 KB | Output is correct |
2 | Correct | 21 ms | 1988 KB | Output is correct |
3 | Correct | 41 ms | 3788 KB | Output is correct |
4 | Correct | 28 ms | 4088 KB | Output is correct |
5 | Correct | 12 ms | 2252 KB | Output is correct |
6 | Correct | 22 ms | 4056 KB | Output is correct |
7 | Correct | 26 ms | 4716 KB | Output is correct |
8 | Correct | 20 ms | 1988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |