답안 #40854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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]) );
                ^
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -