Submission #40854

# Submission time Handle Problem Language Result Execution time Memory
40854 2018-02-09T12:52:07 Z IvanC Fireworks (APIO16_fireworks) C++14
7 / 100
2 ms 560 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 200;
ll N,M,cost;
vector<ll> ordenado;
ll tenta(ll custo){
	ll tot = 0;
	for(ll val : ordenado) tot += abs(val - custo);
	return tot;
}
int main(){
	cin >> N >> M;
	for(ll i = 2;i<=N+M;i++){
		ll p,c;
		cin >> p >> c;
		if(p == 1){
			ordenado.push_back(c);
		}
		else{
			cost += c;
		}
	}
	ll best = tenta(ordenado[0]);
	for(ll i = 1;i<=ordenado.size();i++) best = min(best, tenta(ordenado[i]) );
	cout << cost + best << endl;
	return 0;
}

Compilation message

fireworks.cpp: In function 'int main()':
fireworks.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ll i = 1;i<=ordenado.size();i++) best = min(best, tenta(ordenado[i]) );
                ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 540 KB Output is correct
9 Correct 1 ms 560 KB Output is correct
10 Correct 1 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 540 KB Output is correct
9 Correct 1 ms 560 KB Output is correct
10 Correct 1 ms 560 KB Output is correct
11 Incorrect 2 ms 560 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 540 KB Output is correct
9 Correct 1 ms 560 KB Output is correct
10 Correct 1 ms 560 KB Output is correct
11 Incorrect 2 ms 560 KB Output isn't correct
12 Halted 0 ms 0 KB -