Submission #129008

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

Compilation message (stderr)

cake3.cpp: In function 'int main()':
cake3.cpp:21:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(S.size() >= m - 2) {
                ~~~~~~~~~^~~~~~~~
cake3.cpp:16: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:17: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, c + i);
                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...