# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
361817 | Lawliet | Money (IZhO17_money) | C++17 | 1334 ms | 51456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;
const int MAXN = 1000010;
const int INF = 1000000010;
int n;
int v[MAXN];
set<int> s;
void add(int L, int R)
{
while( L <= R )
s.insert( v[L++] );
}
void solveTestCase()
{
scanf("%d",&n);
for(int i = 1 ; i <= n ; i++)
scanf("%d",&v[i]);
int ans = 1, opt = 1;
int Lvalue = v[1], Rvalue = INF;
for(int i = 2 ; i <= n ; i++)
{
if( v[i - 1] > v[i] )
add( opt , i - 1 ), opt = i;
if( opt == 1 ) continue;
if( opt != i && v[i] <= Rvalue ) continue;
ans++;
auto it = s.upper_bound( v[i] );
if( it == s.end() ) Rvalue = INF;
else Rvalue = *it;
if( it == s.begin() ) Lvalue = -INF;
else it--, Lvalue = *it;
}
printf("%d\n",ans);
}
int main()
{
int t = 1;
// scanf("%d",&t);
while( t-- )
solveTestCase();
}
컴파일 시 표준 에러 (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... |