Submission #802692

#TimeUsernameProblemLanguageResultExecution timeMemory
802692acatmeowmeowLet's Win the Election (JOI22_ho_t3)C++11
10 / 100
5 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, K; cin >> n >> K; vector<int> a(n + 5), b(n + 5), index; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; vector<int> arr(a); sort(arr.begin() + 1, arr.begin() + n + 1); double ans = 0; for (int i = 1; i <= K; i++) ans += (double)arr[i]; for (int i = 1; i <= n; i++) if (b[i] != -1) index.push_back(i); sort(index.begin(), index.end(), [&](int x, int y){ return b[x] < b[y]; }); vector<int> mark(n + 5); double prefix = 0; int cnt = 0; for (auto&i : index) { mark[i] = true; cnt++; prefix += (double)b[i]/cnt; double res = prefix; vector<int> rem; for (int j = 1; j <= n; j++) if (!mark[j]) rem.push_back(j); sort(rem.begin(), rem.end(), [&](int x, int y) { return a[x] < a[y]; }); for (int j = 0, cur = cnt; j < rem.size() && cur < K; j++, cur++) res += (double)a[rem[j]]/(cnt + 1); ans = min(ans, res); } cout << fixed << setprecision(10) << ans << '\n'; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:31:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for (int j = 0, cur = cnt; j < rem.size() && cur < K; j++, cur++) res += (double)a[rem[j]]/(cnt + 1);
      |                              ~~^~~~~~~~~~~~
#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...