# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
963179 | noobcodur | Global Warming (CEOI18_glo) | C++14 | 48 ms | 9440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ld = long double;
#define int long long
#define pii pair<int,int>
#define forn(i,j) for(int i = 0; i < j; ++i)
#define forrange(i,j,k) for(int i = j; i < k; ++i)
#define vi vector<int>
#define vpii vector<pii>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
const int MOD = 1e9+7; const int INF = 1e17+1; const int maxN = 2e5+1;
void setIO(string name){
ios_base::sync_with_stdio(0);
cin.tie(0);
if(!name.empty()){
freopen((name + ".in").c_str(),"r",stdin);
freopen((name + ".out").c_str(),"w",stdout);
}
}
int l[maxN],r[maxN];
signed main(){
setIO("");
int n,x; cin >> n >> x;
vi a(n),b(n);
forn(i,n){
cin >> a[i];
b[i] = -a[i];
}
vi dp;
forn(i,n){
if(dp.empty() || dp.back() < a[i]){
dp.pb(a[i]);
l[i] = dp.size();
continue;
}
int j = lower_bound(all(dp),a[i]) - dp.begin();
dp[j] = a[i];
l[i] = j+1;
}
dp.clear();
for(int i = n-1; i >= 0; --i){
int j = lower_bound(all(dp),b[i]+x) - dp.begin();
r[i] = j+1;
j = lower_bound(all(dp),b[i]) - dp.begin();
if(j == dp.size()){
dp.pb(b[i]);
}
else{
dp[j] = b[i];
}
}
int res = 0;
forn(i,n){
res = max(res,l[i]+r[i]-1);
}
cout << res << endl;
}
컴파일 시 표준 에러 (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... |