이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
llo n,m;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m;
vector<pair<llo,llo>> ss;
for(llo i=0;i<n;i++){
llo aa,bb;
cin>>aa>>bb;
ss.pb({bb,aa});
}
sort(ss.begin(),ss.end());
llo la=-1;
llo ans=0;
/* for(auto j:ss){
cout<<j.a<<"."<<j.b<<endl;
}*/
for(llo i=0;i<n;i++){
llo su=ss[i].b+2*ss[i].a;
priority_queue<llo> tt;
pair<llo,llo> ma={-1,-1};
for(llo j=i+1;j<n;j++){
while(tt.size()>m-2){
su+=tt.top();
tt.pop();
}
// if(j>=la){
if(tt.size()>=m-2){
pair<llo,llo> cur={su+ss[j].b-ss[j].a*2,j};
if(cur.a>ma.a){
ma=cur;
}
/* if(cur.a==20){
cout<<i<<":"<<j<<endl;
}*/
}
//}
su+=ss[j].b;
tt.push(-ss[j].b);
}
ans=max(ans,ma.a);
la=ma.b;
}
cout<<ans<<endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
cake3.cpp: In function 'int main()':
cake3.cpp:32:19: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'llo' {aka 'long long int'} [-Wsign-compare]
32 | while(tt.size()>m-2){
| ~~~~~~~~~^~~~
cake3.cpp:37:17: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'llo' {aka 'long long int'} [-Wsign-compare]
37 | if(tt.size()>=m-2){
| ~~~~~~~~~^~~~~
cake3.cpp:22:6: warning: variable 'la' set but not used [-Wunused-but-set-variable]
22 | llo la=-1;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |