# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
708011 | TAhmed33 | Baloni (COCI15_baloni) | C++98 | 273 ms | 11852 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int arr[n + 1] = {0};
unordered_map<int, deque<int>> pos;
int mx = 0;
int mn = 1e9;
for (int i = 1; i <= n; i++) {
cin >> arr[i];
mx = max(mx, arr[i]);
mn = min(mn, arr[i]);
pos[arr[i]].push_back(i);
}
int ans = 0;
while (mx >= mn) {
if (pos[mx].size() == 0) {
mx--;
continue;
}
int arrow = mx;
int cur = pos[mx].front();
arrow--;
pos[mx].pop_front();
while (arrow != 0) {
if (pos[arrow].size() == 0) break;
int ub = upper_bound(pos[arrow].begin(), pos[arrow].end(), cur) - pos[arrow].begin();
if (ub == pos[arrow].size()) {
break;
}
cur = pos[arrow][ub];
pos[arrow].erase(pos[arrow].begin() + ub);
arrow--;
}
ans++;
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |