# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
716599 | nonono | Global Warming (CEOI18_glo) | C++17 | 119 ms | 4220 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#define SZ(x) (int)(x.size())
using namespace std;
const int mxN = 2e5 + 10;
int n, x, a[mxN];
int dp[mxN];
signed main(){
#define file "test"
if(fopen(file".inp", "r")){
freopen(file".inp", "r", stdin);
freopen(file".out", "w", stdout);
}
ios_base::sync_with_stdio();
cin.tie(); cout.tie();
cin >> n >> x;
for(int i = 1; i <= n; i ++){
cin >> a[i];
}
vector<int> f;
for(int i = 1; i <= n; i ++){
int pos = lower_bound(f.begin(), f.end(), a[i]) - f.begin();
if(pos == SZ(f)) f.push_back(a[i]);
f[pos] = a[i];
dp[i] = pos + 1;
}
f.clear();
int res = 0;
for(int i = n; i >= 1; i --){
int pos = lower_bound(f.begin(), f.end(), - a[i] + x) - f.begin();
res = max(res, dp[i] + pos);
pos = lower_bound(f.begin(), f.end(), - a[i]) - f.begin();
if(pos == SZ(f)) f.push_back(- a[i]);
f[pos] = - a[i];
}
cout << max(res, dp[n]) << "\n";
return 0;
}
컴파일 시 표준 에러 (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... |