Submission #153730

# Submission time Handle Problem Language Result Execution time Memory
153730 2019-09-15T14:35:16 Z BabinSinko Akcija (COCI15_akcija) C++14
80 / 80
66 ms 2424 KB
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>

using namespace std;

long long n, c[100003], sol, x;

int compare (const void * a, const void * b){
  return ( *(int*)a - *(int*)b );
}
int main(){
cin >> n;
for (int i; i < n; i++){
	cin >> c[i];
	sol = sol + c[i];
}
x = 1;
qsort (c, n, sizeof(long long), compare);
for (int i = (n - 1); i >= 0; i--){	
	if (x % 3 == 0){
		sol = sol - c[i];
		x = 0;
	}
	x = x + 1;
}
cout << sol;
return 0;
}

Compilation message

akcija.cpp: In function 'int main()':
akcija.cpp:17:15: warning: 'i' is used uninitialized in this function [-Wuninitialized]
 for (int i; i < n; i++){
             ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 404 KB Output is correct
6 Correct 52 ms 2296 KB Output is correct
7 Correct 43 ms 1920 KB Output is correct
8 Correct 44 ms 1908 KB Output is correct
9 Correct 66 ms 2424 KB Output is correct
10 Correct 65 ms 2424 KB Output is correct