Submission #13724

#TimeUsernameProblemLanguageResultExecution timeMemory
13724gs14004즐거운 채소 기르기 (JOI14_growing)C++14
45 / 100
209 ms1084 KiB
#include <cstdio> #include <algorithm> using namespace std; int main(){ int n,a[5005]; scanf("%d",&n); for (int i=0; i<n; i++) { scanf("%d",&a[i]); } int ret = 0; for (int i=0; i<n; i++) { int p = (int)(min_element(a,a+n) - a); int cnt1 = 0, cnt2 = 0; for (int i=0; i<p; i++) { if(a[i] <= 1e9 && a[i] > a[p]) cnt1++; } for (int i=p+1; i<n; i++) { if(a[i] <= 1e9 && a[i] > a[p]) cnt2++; } a[p] = 2e9; ret += min(cnt1,cnt2); } printf("%d",ret); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...