Submission #129024

#TimeUsernameProblemLanguageResultExecution timeMemory
129024PeppaPigCake 3 (JOI19_cake3)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define long long long #define pii pair<long, long> #define x first #define y second using namespace std; const int N = 2e5+5; int n, m; pii v[N]; long ans = -1e18; int main() { scanf("%d %d", &n, &m); for(int i = 1; i <= n; i++) scanf("%lld %lld", &v[i].x, &v[i].y); sort(v + 1, v + n + 1, [&](const pii &a, const pii &b) { return a.y < b.y; }); for(int i = 1; i <= n - m + 1; i++) { multiset<pii, greater<pii> > S; long ret = v[i].x + v[i + m - 1].x; for(int j = 1; j <= m - 2; j++) ret += v[i + j].x; ret -= 2 * (v[i + m - 1].y - v[i].y); ans = max(ans, ret); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

cake3.cpp: In function 'int main()':
cake3.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
cake3.cpp:18:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%lld %lld", &v[i].x, &v[i].y);
                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...