Submission #802945

#TimeUsernameProblemLanguageResultExecution timeMemory
802945acatmeowmeowLet's Win the Election (JOI22_ho_t3)C++11
10 / 100
5 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double 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 = 1; for (auto&i : index) { mark[i] = true; prefix += (double)b[i]/cnt; 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; ans = min(ans, res); } cout << fixed << setprecision(10) << ans << '\n'; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:32: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]
   32 |   for (int j = 0, cur = cnt; j < rem.size() && cur <= K; j++, cur++) res += (double)a[rem[j]]/cnt;
      |                              ~~^~~~~~~~~~~~
#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...