Submission #128749

#TimeUsernameProblemLanguageResultExecution timeMemory
128749sealnot123Cake 3 (JOI19_cake3)C++14
24 / 100
148 ms508 KiB
#include<bits/stdc++.h> #define x first #define y second #define pb push_back #define eb emplace_back #define all(a) (a).begin(),(a).end() #define SZ(a) (int)(a).size() using namespace std; typedef long long LL; typedef pair<LL,LL> PLL; typedef pair<int,int> PII; typedef double D; typedef long double LD; const int N = 2005; LL ans = -1e18, sum; PLL cook[N]; int n,m; priority_queue<int> val; int main(){ int i,j,k,l,a,b,c,d; scanf("%d%d",&n,&m); for(i=1;i<=n;i++){ scanf("%lld%lld",&cook[i].y,&cook[i].x); } sort(cook+1, cook+1+n); for(i=m;i<=n;i++){ sum = 0; for(j=i;j>=1;j--){ sum += cook[j].y; val.push(-cook[j].y); if(SZ(val) > m) sum += val.top(), val.pop(); if(SZ(val) == m) ans = max(ans, sum - 2*(cook[i].x-cook[j].x)); } while(!val.empty()) val.pop(); } printf("%lld",ans); return 0; }

Compilation message (stderr)

cake3.cpp: In function 'int main()':
cake3.cpp:20:10: warning: unused variable 'k' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
          ^
cake3.cpp:20:12: warning: unused variable 'l' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
            ^
cake3.cpp:20:14: warning: unused variable 'a' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
              ^
cake3.cpp:20:16: warning: unused variable 'b' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
                ^
cake3.cpp:20:18: warning: unused variable 'c' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
                  ^
cake3.cpp:20:20: warning: unused variable 'd' [-Wunused-variable]
  int i,j,k,l,a,b,c,d;
                    ^
cake3.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
cake3.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",&cook[i].y,&cook[i].x);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...