| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 762561 | KN200711 | Baloni (COCI15_baloni) | C++14 | 471 ms | 131072 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
using namespace std;
int arr[1000001];
bool vis[1000001];
set<int> pos[1000001];
int main() {
int N;
scanf("%d", &N);
for(int i=1;i<=N;i++) {
scanf("%d", &arr[i]);
pos[arr[i]].insert(i);
vis[i] = 0;
}
int ans = 0;
for(int i=1;i<=N;i++) {
if(vis[i]) continue;
int K = i + 1, H = arr[i] - 1;
vis[i] = 1;
ans++;
while(H) {
// cout<<H<<endl;
auto p = pos[H].lower_bound(K);
if(p == pos[H].end()) break;
// cout<<"vis"<<endl;
vis[*p] = 1;
K = *p + 1;
H--;
pos[H].erase(p);
}
}
printf("%d\n", ans);
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
