Submission #819379

#TimeUsernameProblemLanguageResultExecution timeMemory
819379AdamGSCake 3 (JOI19_cake3)C++17
24 / 100
4038 ms7928 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const ll INF=1e18+7; const int LIM=2e5+7; pair<ll,ll>T[LIM]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n, m, ans=-INF; cin >> n >> m; rep(i, n) cin >> T[i].nd >> T[i].st; sort(T, T+n); rep(i, n) { priority_queue<ll>q; ll akt=0; for(int j=i+1; j<n; ++j) { if(q.size()==m-2) ans=max(ans, akt-2*T[j].st+2*T[i].st+T[i].nd+T[j].nd); q.push(-T[j].nd); akt+=T[j].nd; if(q.size()>m-2) { akt+=q.top(); q.pop(); } } } cout << ans << '\n'; }

Compilation message (stderr)

cake3.cpp: In function 'int main()':
cake3.cpp:22:15: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |    if(q.size()==m-2) ans=max(ans, akt-2*T[j].st+2*T[i].st+T[i].nd+T[j].nd);
      |       ~~~~~~~~^~~~~
cake3.cpp:25:15: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   25 |    if(q.size()>m-2) {
      |       ~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...