제출 #450217

#제출 시각아이디문제언어결과실행 시간메모리
450217blueCake 3 (JOI19_cake3)C++17
5 / 100
4046 ms500 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <cassert> using namespace std; int main() { int N, M; cin >> N >> M; long long V[N], C[N]; for(int i = 0; i < N; i++) cin >> V[i] >> C[i]; long long res = -1'000'000'000'000'000'000LL; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { if(i == j) continue; if(C[i] > C[j]) continue; multiset<long long> H; for(int k = 0; k < N; k++) { if(k == i || k == j) continue; if(C[k] < C[i] || C[j] < C[k]) continue; H.insert(V[k]); } while(H.size() > M-2) H.erase(H.find(*H.begin())); // cerr << i << ' ' << j << ": "; // for(long long h:H) cerr << h << ' '; // cerr << '\n'; if(H.size() < M-2) continue; long long curr = -2*(C[j] - C[i]) + V[i] + V[j]; for(long long q: H) curr += q; res = max(res, curr); } } cout << res << '\n'; }

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

cake3.cpp: In function 'int main()':
cake3.cpp:32:28: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |             while(H.size() > M-2) H.erase(H.find(*H.begin()));
      |                   ~~~~~~~~~^~~~~
cake3.cpp:38:25: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |             if(H.size() < M-2) continue;
      |                ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...