Submission #25786

# Submission time Handle Problem Language Result Execution time Memory
25786 2017-06-24T06:49:07 Z 서규호(#1081) 즐거운 채소 기르기 (JOI14_growing) C++14
0 / 100
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,it;
		for(int j=1; j<=N; j++){
			if(check[j]) continue;
			if(small > a[j]){
				small = a[j];
				it = j;
			}
		}
		check[it] = true;
		int lcnt,rcnt;
		lcnt = rcnt = 0;
		for(int j=1; j<it; j++){
			if(!check[j]) lcnt++;
		}
		for(int j=it+1; j<=N; j++){
			if(!check[j]) rcnt++;
		}
		ans += (lld)min(lcnt,rcnt);
	}
	printf("%lld\n",ans);

	return 0;
}

Compilation message

growing.cpp: In function 'int main()':
growing.cpp:21:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
                ^
growing.cpp:23:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
                    ^
growing.cpp:34:19: warning: 'it' may be used uninitialized in this function [-Wmaybe-uninitialized]
   check[it] = true;
                   ^
# 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 Incorrect 0 ms 3484 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3484 KB Output is correct
2 Incorrect 0 ms 3484 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 3484 KB Execution timed out
2 Halted 0 ms 0 KB -