| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1050386 | anton | Global Warming (CEOI18_glo) | C++17 | 182 ms | 26080 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
int N, X;
struct MaxTree{
int len = 1;
vector<int> tr;
MaxTree(int n){
while(len<n){
len*=2;
}
tr.resize(2*len);
}
void upd(int u){
for(u/=2; u>=1; u/=2){
tr[u] = max(tr[u*2], tr[u*2+1]);
}
}
int get(int l, int r){
l += len;
r+=len+1;
int res = 0;
for(; l<r; l/=2, r/=2){
if(l%2 ==1){
res = max(res, tr[l++]);
}
if(r%2 == 1){
res = max(res, tr[--r]);
}
}
return res;
}
void set(int pos, int val){
pos+=len;
tr[pos] = max(tr[pos], val);
upd(pos);
}
};
int find_pos(int e, vector<int>& v){
int pos =0;
for(int step = (1LL<<20); step>=1; step/=2){
if(pos+step<v.size() && v[pos+step]<=e){
pos+=step;
}
}
return pos;
}
vector<int> vals;
int lis(vector<pii>& v){
MaxTree low(vals.size());
MaxTree high(vals.size());
for(int i= 0; i<N; i++){
int best_high = max(high.get(0, v[i].first-1), low.get(0, v[i].second-1));
high.set(v[i].first, best_high+1);
int best_low = low.get(0, v[i].first-1);
low.set(v[i].first, best_low+1);
}
return high.get(0, vals.size()-1);
}
signed main(){
cin>>N>>X;
vector<pii> t(N);
vals.push_back(0);
for(int i = 0; i<N; i++){
cin>>t[i].first;
vals.push_back(t[i].first);
vals.push_back(t[i].first+X);
}
sort(vals.begin(), vals.end());
for(int i = 0; i<N; i++){
t[i] ={find_pos(t[i].first, vals), find_pos(t[i].first+X, vals)};
}
cout<<lis(t)<<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... | ||||
