제출 #128159

#제출 시각아이디문제언어결과실행 시간메모리
128159mahmoudbadawyCake 3 (JOI19_cake3)C++17
24 / 100
320 ms3320 KiB
#include <bits/stdc++.h> #define F first #define S second using namespace std; const int N=100005; pair<int,int> arr[N]; int n,m; int main() { scanf("%d %d",&n,&m); for(int i=0;i<n;i++) scanf("%d %d",&arr[i].S,&arr[i].F); sort(arr,arr+n); long long ans=-(1LL<<60); for(int i=0;i<n;i++) { multiset<int> ss; long long curv=0; for(int j=i;j<n;j++) { ss.insert(arr[j].S); curv+=arr[j].S; if(ss.size()>m) { curv-=(*ss.begin()); ss.erase(ss.begin()); } if(ss.size()==m) { //cout << i << " " << j << " " << curv << " " << arr[j].F-arr[i].F << endl; ans=max(ans,curv-2*(arr[j].F-arr[i].F)); } } } printf("%lld\n",ans); }

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

cake3.cpp: In function 'int main()':
cake3.cpp:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(ss.size()>m)
       ~~~~~~~~~^~
cake3.cpp:32:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(ss.size()==m)
       ~~~~~~~~~^~~
cake3.cpp:14: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:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&arr[i].S,&arr[i].F);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...