# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
477870 | sumit_kk10 | 지구 온난화 (NOI13_gw) | C++17 | 503 ms | 65540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
int n;
vector<ll> a(N);
void solve(){
cin >> n;
for(int i = 0; i < n; ++i)
cin >> a[i];
vector<pair<long long, int> > comp;
for(int i = 0; i < n; ++i)
comp.push_back({a[i], i});
sort(comp.begin(), comp.end());
int ct = 1;
a[comp[0].second] = ct;
for(int i = 1; i < comp.size(); ++i){
if(comp[i].first != comp[i - 1].first)
++ct;
a[comp[i].second] = ct;
}
vector<int> pos[ct + 2];
for(int i = 0; i < n; ++i)
pos[a[i]].push_back(i);
int x = 0;
for(int j = 0; j < n; ++j){
int cur = j;
while(a[cur] > 1 and cur < n)
++cur;
if(cur != j){
j = cur - 1;
++x;
}
}
map<int, bool> mp;
for(auto k : pos[1])
mp[k] = true;
int ans = x;
for(int i = 2; i <= ct; ++i){
for(auto k : pos[i]){
if(k >= 1 and mp[k - 1] and mp[k + 1]){
--x;
mp[k] = true;
continue;
}
if(k >= 1 and mp[k - 1]){
if(k == n - 1) --x;
mp[k] = true;
continue;
}
if(mp[k + 1]){
if(k == 0) --x;
mp[k] = true;
continue;
}
if(k != 0 and k != n - 1)
x++;
mp[k] = true;
}
ans = max(ans, x);
}
cout << ans << "\n";
}
int main(){
fast;
int t = 1;
// cin >> t;
while(t--)
solve();
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... |