# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168601 | 2019-12-14T06:35:49 Z | Gurban | Money (IZhO17_money) | C++14 | 2 ms | 376 KB |
#include <bits/stdc++.h> #define pb push_back #define ss second #define ff first #define N 2000006 #define inf 1000000009 #define ll long long #define mid(a,b) (a+b)/2 using namespace std; int n,a[N],sub,vis[N],pos,mn = 1e9; map<int,int> p; vector <pair<int,int>> v; void fn(int ind,int pr){ if(p[ind] == 0) return; if(vis[p[ind]]) return; if(ind + 1 != p[ind]) sub++; if(ind + 1 != p[ind] and ((a[ind + 1] > a[ind] and a[ind + 1] <= pr) or a[p[ind]] == a[ind + 1])){ vis[ind + 1] = 1; pr = a[ind + 1]; fn(ind + 1,1e9); } fn(p[ind],pr); } int main() { scanf("%d",&n); for(int i = 1;i <= n;i++){ scanf("%d",&a[i]); v.pb({a[i],i}); if(a[i] < mn){ mn = a[i]; pos = i; } } sort(v.begin(),v.end()); for(int i = 0;i < v.size() - 1;i++) p[v[i].ss] = v[i + 1].ss; a[n + 1] = -1e9; sub++; fn(pos,1e9); printf("%d",sub); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |