# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25794 | 2017-06-24T07:19:48 Z | 서규호(#1081) | 즐거운 채소 기르기 (JOI14_growing) | C++14 | 1000 ms | 3484 KB |
#include <bits/stdc++.h> #define lld long long #define pp pair<int,int> #define pb push_back #define MOD 1000000007 #define left lleft #define right rright #define INF 2000000000 #define Linf 1000000000000000000LL #define next nnext #define minus mminus using namespace std; int N,nn; lld ans; int a[300002]; bool check[300002]; int main(){ scanf("%d",&N); for(int i=1; i<=N; i++){ scanf("%d",&a[i]); } for(int i=1; i<=N; i++){ int small = INF,it1,it2; for(int j=1; j<=N; j++){ if(check[j]) continue; if(small > a[j]){ small = a[j]; it1 = j; } } for(int j=N; j>=1; j--){ if(small == a[j] && !check[j]){ it2 = j; break; } } int lcnt = 0,rcnt = 0; for(int j=1; j<it1; j++) if(!check[j]) lcnt++; for(int j=it2+1; j<=N; j++) if(!check[j]) rcnt++; if(lcnt <= rcnt) check[it1] = true; else check[it2] = true; ans += min(lcnt,rcnt); } printf("%lld\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3484 KB | Output is correct |
2 | Correct | 0 ms | 3484 KB | Output is correct |
3 | Correct | 0 ms | 3484 KB | Output is correct |
4 | Correct | 0 ms | 3484 KB | Output is correct |
5 | Correct | 0 ms | 3484 KB | Output is correct |
6 | Correct | 0 ms | 3484 KB | Output is correct |
7 | Correct | 0 ms | 3484 KB | Output is correct |
8 | Correct | 0 ms | 3484 KB | Output is correct |
9 | Correct | 0 ms | 3484 KB | Output is correct |
10 | Correct | 0 ms | 3484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3484 KB | Output is correct |
2 | Correct | 0 ms | 3484 KB | Output is correct |
3 | Correct | 0 ms | 3484 KB | Output is correct |
4 | Correct | 0 ms | 3484 KB | Output is correct |
5 | Correct | 0 ms | 3484 KB | Output is correct |
6 | Correct | 0 ms | 3484 KB | Output is correct |
7 | Correct | 0 ms | 3484 KB | Output is correct |
8 | Correct | 0 ms | 3484 KB | Output is correct |
9 | Correct | 0 ms | 3484 KB | Output is correct |
10 | Correct | 0 ms | 3484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3484 KB | Output is correct |
2 | Correct | 6 ms | 3484 KB | Output is correct |
3 | Correct | 16 ms | 3484 KB | Output is correct |
4 | Correct | 53 ms | 3484 KB | Output is correct |
5 | Correct | 49 ms | 3484 KB | Output is correct |
6 | Correct | 113 ms | 3484 KB | Output is correct |
7 | Correct | 39 ms | 3484 KB | Output is correct |
8 | Correct | 79 ms | 3484 KB | Output is correct |
9 | Correct | 123 ms | 3484 KB | Output is correct |
10 | Correct | 49 ms | 3484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 3484 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |