Submission #153189

#TimeUsernameProblemLanguageResultExecution timeMemory
153189fedoseevtimofeyCake 3 (JOI19_cake3)C++14
0 / 100
3 ms376 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, m; cin >> n >> m; vector <pair <int, int>> a(n); for (int i = 0; i < n; ++i) cin >> a[i].second >> a[i].first; sort(a.begin(), a.end()); ll ans = 0; for (int i = 0; i < n; ++i) { multiset <int> cur; for (int j = i; j < n; ++j) { cur.insert(a[j].second); if (cur.size() >= m) { ll res = 0; auto uk = --cur.end(); for (int k = 0; k < m; ++k) { res += *uk; if (k + 1 < m) --uk; } ans = max(ans, res - 2LL * a[j].first + 2LL * a[i].first); } } } cout << ans << '\n'; }

Compilation message (stderr)

cake3.cpp: In function 'int main()':
cake3.cpp:24:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (cur.size() >= m) {
                 ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...