# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40854 | IvanC | Fireworks (APIO16_fireworks) | C++14 | 2 ms | 560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |