| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 36244 | touristk2000 | Money (IZhO17_money) | C++14 | 556 ms | 17648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e6 + 1;
int main(){
int n;
scanf("%d", &n);
vector<int> a(n);
vector<int> cnt(MAXN);
for (int i = 0; i < n; ++i)
{
scanf("%d", &a[i]);
cnt[a[i]]++;
}
vector<int> pr(MAXN + 1), nxt(MAXN + 1, MAXN);
{
int lst = 0;
for (int i = 1; i <= MAXN; ++i)
{
pr[i] = lst;
if (cnt[i])
nxt[lst] = i, lst = i;
}
}
int ans = 0;
for (int i = n - 1; i >= 0;)
{
++ans;
int j = i;
while (i > 0)
{
int p = pr[a[i]];
if (a[i - 1] == a[i])
{
if (cnt[a[i]] == 1)
{
int l = pr[a[i]];
int r = nxt[a[i]];
pr[r] = l;
nxt[l] = r;
}
--cnt[a[i]];
--i;
}
else
{
if (p == a[i - 1] && (cnt[a[i]] == 1 || a[j] == a[i]))
{
if (cnt[a[i]] == 1)
{
int l = pr[a[i]];
int r = nxt[a[i]];
pr[r] = l;
nxt[l] = r;
}
--cnt[a[i]];
--i;
}
else
{
break;
}
}
}
if (cnt[a[i]] == 1)
{
int l = pr[a[i]];
int r = nxt[a[i]];
pr[r] = l;
nxt[l] = r;
}
--cnt[a[i]];
--i;
}
printf("%d\n", ans);
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... | ||||
