제출 #146464

#제출 시각아이디문제언어결과실행 시간메모리
146464jwvg0425Cake 3 (JOI19_cake3)C++17
24 / 100
4006 ms9836 KiB
#include <stdio.h> #include <vector> #include <queue> #include <algorithm> #include <iostream> #include <string> #include <bitset> #include <map> #include <set> #include <tuple> #include <string.h> #include <math.h> #include <random> #include <functional> #include <assert.h> #include <math.h> #define all(x) (x).begin(), (x).end() #define xx first #define yy second using namespace std; using i64 = long long int; using ii = pair<int, int>; using ii64 = pair<i64, i64>; int main() { int n, m; scanf("%d %d", &n, &m); vector<ii64> cakes(n); for (int i = 0; i < n; i++) scanf("%lld %lld", &cakes[i].xx, &cakes[i].yy); sort(all(cakes), [](const ii64& l, const ii64& r) { if (l.yy == r.yy) return l.xx > r.xx; return l.yy < r.yy; }); i64 ans = -1ll << 61; for (int sc = 0; sc < n; sc++) { multiset<i64> largest; i64 sum = cakes[sc].xx; for (int bc = sc + 2; bc < n; bc++) { if (largest.size() < m - 2) { largest.insert(cakes[bc - 1].xx); sum += cakes[bc - 1].xx; } else if (*largest.begin() < cakes[bc - 1].xx) { sum += cakes[bc - 1].xx; sum -= *largest.begin(); largest.erase(largest.begin()); largest.insert(cakes[bc - 1].xx); } i64 total = sum + cakes[bc].xx - 2 * (cakes[bc].yy - cakes[sc].yy); if (largest.size() == m - 2 && total > ans) ans = total; } } printf("%lld\n", ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

cake3.cpp: In function 'int main()':
cake3.cpp:55:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (largest.size() < m - 2)
                 ~~~~~~~~~~~~~~~^~~~~~~
cake3.cpp:70:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (largest.size() == m - 2 && total > ans)
                 ~~~~~~~~~~~~~~~^~~~~~~~
cake3.cpp:31: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:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &cakes[i].xx, &cakes[i].yy);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...