# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
229341 | 2020-05-04T09:10:43 Z | DodgeBallMan | Money (IZhO17_money) | C++14 | 5 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, a[N], s[N], cnt, ans; set<int> se; void process( int idx ) { //printf("%d\n",idx); int l = s[idx], r = s[idx+1] - 1; //printf("L : %d R : %d\n",l,r); while( l < r ) { int mid = l + r + 1 >> 1; //printf("MID : %d %d\n",mid,s[mid]); if( se.upper_bound( a[s[idx]] ) == se.lower_bound( a[mid] ) ) l = mid; else r = mid - 1; } for( int i = s[idx] ; i <= l ; i++ ) se.insert( a[i] ); s[idx] = l + 1; //printf("L : %d\n",l); ans++; return ; } int main() { scanf("%d",&n); for( int i = 1 ; i <= n ; i++ ) scanf("%d",&a[i]); a[0] = 2e9; for( int i = 1 ; i <= n ; i++ ) if( a[i] < a[i-1] ) s[++cnt] = i; s[++cnt] = n+1; /*for( int i = 1 ; i <= cnt ; i++ ) printf("%d ", s[i]); printf("\n");*/ for( int i = 1 ; i < cnt ; i++ ) { do{ process( i ); }while( s[i] < s[i+1] ); } printf("%d",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Incorrect | 5 ms | 384 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Incorrect | 5 ms | 384 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Incorrect | 5 ms | 384 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Incorrect | 5 ms | 384 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |