제출 #36949

#제출 시각아이디문제언어결과실행 시간메모리
36949nickyrioMoney (IZhO17_money)C++14
45 / 100
1500 ms51204 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = a; i<=b ; i++) #define FORD(i, a, b) for (int i = a; i>=b; i--) #define REP(i, a) for (int i = 0; i<a; i++) #define N 1001000 #define pp pair<int, int> #define IO cin.tie(NULL);cout.tie(NULL); #define bit(S, i) (((S) >> i) & 1) template<typename T> inline void read(T &x) { char c; bool neg = false; while (!isdigit(c = getchar()) && c != '-'); x = 0; if (c == '-') { neg = true; c = getchar(); } do { x = x * 10 + c - '0'; } while (isdigit(c = getchar())); if (neg) x = -x; } template<typename T> inline void write(T x) { if (x < 0) { putchar('-'); write(-x);return; } if (x < 10) { putchar(char(x + 48)); } else { write(x/10); putchar(char(48 + x%10)); } } template<typename T> inline void writeln(T x) { write(x); putchar('\n'); } using namespace std; int n, a[N]; set<int> used; int main() { IO; read(n); FOR(i, 1, n) read(a[i]); int start = 1; int cnt = 0; while (start <= n) { cnt++; int last = start + 1; used.insert(a[start]); int lim; if (used.upper_bound(a[start]) == used.end()) lim = 1e9; else lim = *used.upper_bound(a[start]); while (last <= n && a[last] <= lim && a[last] >= a[last - 1]) { used.insert(a[last]); last++; } start = last; } writeln(cnt); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...