이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = -5e18;
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';
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |