Submission #648222

#TimeUsernameProblemLanguageResultExecution timeMemory
648222baibhav26062008Let's Win the Election (JOI22_ho_t3)C++14
5 / 100
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n,k; cin >> n >> k; int a[n],b[n]; bool got = false; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; if (b[i] != -1) got = true; } sort(a,a+n); int h = 0; if (!got) { for (int i = 0; i < k; i++) { h += a[i]; } } else { sort(b,b+n); int i = 0; while (k != 0) { if (i == 0) h += a[0] + b[0]; i++; k--; h += (a[i]/2); } } cout << h << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...