Submission #40854

#TimeUsernameProblemLanguageResultExecution timeMemory
40854IvanCFireworks (APIO16_fireworks)C++14
7 / 100
2 ms560 KiB
#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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...