# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
25789 | 2017-06-24T07:01:43 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]){ 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
# | 결과 | 실행 시간 | 메모리 | 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 | Incorrect | 0 ms | 3484 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3484 KB | Output is correct |
2 | Incorrect | 3 ms | 3484 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 3484 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |