| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1096665 | Top1BUCODE | Global Warming (CEOI18_glo) | C++14 | 213 ms | 10440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N=4e5+5;
int n,t[4*N],a[N],f[N],x,h,u,v,k,res; vector <int> ve;
void update(int id,int l,int r)
{
if (l==r)
{
t[id]=h;
return;
}
int m=(l+r)/2;
if (u<=m) update(id*2,l,m); else update(id*2+1,m+1,r);
t[id]=max(t[id*2],t[id*2+1]);
}
int get(int id,int l,int r)
{
if (v<l) return 0;
if (v>=r) return t[id];
int m=(l+r)/2;
return max(get(id*2,l,m),get(id*2+1,m+1,r));
}
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> x;
x=abs(x);
for (int i=1;i<=n;i++)
{
cin >> a[i];
ve.push_back(a[i]);
ve.push_back(a[i]+x);
}
sort(ve.begin(),ve.end());
ve.resize(unique(ve.begin(),ve.end())-ve.begin());
k=ve.size();
for (int i=1;i<=n;i++)
{
v=lower_bound(ve.begin(),ve.end(),a[i]+x)-ve.begin();
h=get(1,1,k)+1;
u=v+1;
if (f[u]<h)
{
f[u]=h;
update(1,1,k);
res=max(res,f[u]);
}
v=lower_bound(ve.begin(),ve.end(),a[i])-ve.begin();
h=get(1,1,k)+1;
u=v+1;
if (f[u]<h)
{
f[u]=h;
update(1,1,k);
res-max(res,f[u]);
}
}
cout << res;
}
컴파일 시 표준 에러 (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... | ||||
