# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1085631 | Sunbae | 지구 온난화 (NOI13_gw) | C++17 | 989 ms | 65536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define z exit(0)
#define mp make_pair
#define F first
#define S second
using namespace std;
using pii = pair<int,int>;
const int N = 1e6 + 5, inf = 1e9;
int cp[N], a[N], m;
set<pii> s;
vector<int> to_remove[N];
int gw(int n, int H[]){
for(int i = m = 0; i<n; ++i) cp[m++] = H[i];
cp[m++] = 0;
for(int i = 0; i<m; ++i) to_remove[i].clear(); s.clear();
sort(cp, cp+m); m = unique(cp, cp+m) - cp;
for(int i = 0; i<n; ++i) to_remove[a[i] = lower_bound(cp, cp+m, H[i]) - cp].push_back(i);
for(int i = 0, j = 0; i<n; ){
for(; j<n && a[j+1] > 0; ++j){}
s.emplace(i, j);
i = j+2; j = i;
}
int mx = (int)s.size();
for(int t = 1; t<m; ++t){
for(int j : to_remove[t]){
set<pii>::iterator itr = (--s.upper_bound(mp(j, inf)));
if(itr == s.end()) continue;
int l = itr->F, r = itr->S;
s.erase(itr);
if(l <= j-1) s.emplace(l, j-1);
if(j+1 <= r) s.emplace(j+1, r);
}
mx = max(mx, (int)s.size());
}
return mx;
}
signed main(){
int n; scanf("%d", &n);
int H[n];
for(int i = 0; i<n; ++i) scanf("%d", H+i);
printf("%d", gw(n, H));
}
컴파일 시 표준 에러 (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... |