| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 668830 | asdf1234coding | Global Warming (CEOI18_glo) | C++14 | 56 ms | 5952 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 <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;
#define problemname "glo"
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define MOD (int)1e9+7
#define ll long long
#define ff first
#define ss second
bool ckmin(int& a, int b) {return a>b?a=b,true:false;}
bool ckmax(int& a, int b) {return a<b?a=b,true:false;}
int main () {
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen (problemname ".in", "r", stdin); freopen(problemname ".out", "w", stdout);
int n,x;cin>>n>>x;
vi a(n); for(auto& x: a) cin>>x;
vi left;
vi dp;
int ans = 0;
for(auto lmao:a) {
int pos = lower_bound(dp.begin(), dp.end(), lmao) - dp.begin();
if(pos == dp.size()) {
dp.pb(lmao);
} else {
dp[pos]=lmao;
}
left.pb(pos);
// cout<<lmao << ' '<<pos<<endl;
ckmax(ans, left[left.size()-1]);
}
// for(auto x:dp) cout<<x<<' ';
// cout<<endl;
// cout<<ans<<endl;
// cout<<"---------------"<<endl;
dp.clear();
vi right;
for(int i=n-1; i>=0; i--) {
a[i]=-a[i];
int pos = lower_bound(dp.begin(), dp.end(), a[i] + x) - dp.begin();
int ins = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
if(ins == dp.size()) {
dp.pb(a[i]);
} else {
dp[ins]=a[i];
}
right.pb(dp.size());
a[i]=-a[i];
ckmax(ans, left[i]+pos);
// cout<<ans<<' '<<i<<endl;
}
cout<<ans+1<<endl;
return 0;
}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... | ||||
