| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 35197 | ulna | Money (IZhO17_money) | C++11 | 189 ms | 9828 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
// why am I so weak
int n;
int a[1000055];
int dat[1000055];
inline void read(int &x) {
x = 0;
char ch = 0;
while (ch < '0' || ch > '9') ch = getchar();
while (ch >= '0' && ch <= '9') {
x = x * 10 + (ch - '0');
ch = getchar();
}
}
void add(int id) {
int val = id;
while (id < (int)1e6) {
dat[id] = max(dat[id], val);
id |= (id + 1);
}
}
int get(int id) {
int res = -1;
while (id >= 0) {
res = max(res, dat[id]);
id = (id & (id + 1)) - 1;
}
return res;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
read(a[i]);
a[i] = (int)1e6 - a[i];
}
int lb = 0, ub = (int)1e7;
int res = 1;
for (int i = 0; i < n; i++) {
if (lb <= a[i] && a[i] <= ub) {
add(a[i]);
ub = a[i];
continue;
}
ub = a[i];
lb = get(a[i] - 1);
res++;
add(a[i]);
}
printf("%d\n", res);
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... | ||||
