| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 668795 | asdf1234coding | Global Warming (CEOI18_glo) | C++14 | 46 ms | 6068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
for(auto lmao:a) {
int pos = lower_bound(dp.begin(), dp.end(), lmao) - dp.begin();
if(pos == dp.size()) {
dp.pb(x);
} else {
dp[pos]=lmao;
}
left.pb(dp.size());
}
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]) - dp.begin();
if(pos == dp.size()) {
dp.pb(a[i]);
} else {
dp[pos]=a[i];
}
right.pb(dp.size());
a[i]=-a[i];
}
reverse(right.begin(),right.end());
// for(int i=0; i<n; i++) {
// cout<<left[i]<<' ';
// }
// cout<<endl;
// for(int i=0; i<n; i++) {
// cout<<right[i]<<' ';
// }
int ans =right[0];
for(int i=0; i<n-1; i++) {
if(abs(a[i]-a[i+1] < x))
ckmax(ans, left[i]+right[i+1]);
}
ckmax(ans, left[n-1]);
cout<<ans<<endl;
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... | ||||
