제출 #376799

#제출 시각아이디문제언어결과실행 시간메모리
376799casperwangCake 3 (JOI19_cake3)C++14
24 / 100
4074 ms4848 KiB
#include <bits/stdc++.h> #define int long long #define All(x) x.begin(), x.end() #define pii pair<int,int> #define ff first #define ss second using namespace std; #define debug(args...) kout("[ " + string(#args) + " ]", args) void kout() { cerr << endl; } template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); } template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; } const int MAXN = 200000; const int INF = 1e18; int N, M; pii arr[MAXN+1]; int ans = -INF; void solve() { priority_queue <int, vector<int>, greater<int>> val; for (int i = 1; i <= N; i++) { int sum = arr[i].ff + arr[i].ss * 2; for (int j = i+1; j <= N; j++) { if (val.size() == M-2) { ans = max(ans, sum + arr[j].ff - 2 * arr[j].ss); } sum += arr[j].ff; val.push(arr[j].ff); if (val.size() + 2 > M) { sum -= val.top(); val.pop(); } } while (val.size()) val.pop(); } } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> N >> M; for (int i = 1; i <= N; i++) { auto &[v, c] = arr[i]; cin >> v >> c; } sort(arr+1, arr+1+N, [](const pii a, const pii b) { return a.ss < b.ss; }); solve(); cout << ans << '\n'; }

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

cake3.cpp: In function 'void solve()':
cake3.cpp:24:19: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   24 |    if (val.size() == M-2) {
      |        ~~~~~~~~~~~^~~~~~
cake3.cpp:29:23: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   29 |    if (val.size() + 2 > M) {
      |        ~~~~~~~~~~~~~~~^~~
cake3.cpp: In function 'int main()':
cake3.cpp:42:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |   auto &[v, c] = arr[i];
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...