| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 229841 | Lawliet | Money (IZhO17_money) | C++17 | 4 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
int n;
int L[MAXN];
int R[MAXN];
int v[MAXN];
int ord[MAXN];
int firstOcc[MAXN];
void removeSegment(int A, int B)
{
R[ L[A] ] = R[A];
L[ R[B] ] = L[B];
}
int main()
{
scanf("%d",&n);
for(int i = 1 ; i <= n ; i++)
{
scanf("%d",&v[i]);
ord[i] = v[i];
}
sort( ord + 1 , ord + n + 1 );
iota( L + 1 , L + n + 1 , 0 );
iota( R + 1 , R + n + 1 , 2 );
for(int i = n ; i > 0 ; i--)
firstOcc[ ord[i] ] = i;
int ans = 0;
int last = n;
while( last > 0 )
{
ans++;
int p = last;
int aux = last;
while( p > 0 && v[p] == v[last] )
p--;
if( p == 0 ) break;
int curInd = firstOcc[ v[last] ];
firstOcc[ v[last] ] = curInd + last - p;
last = p;
for(int i = p ; i > 0 ; i--)
{
if( v[i] != ord[ L[curInd] ] )
break;
last--;
curInd = L[curInd];
}
removeSegment( last + 1 , aux );
}
printf("%d\n",ans);
}
컴파일 시 표준 에러 (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... | ||||
