제출 #649482

#제출 시각아이디문제언어결과실행 시간메모리
649482groshiCake 3 (JOI19_cake3)C++17
0 / 100
1 ms336 KiB
#include<iostream> #include<vector> #include<algorithm> #define int long long using namespace std; int wynik[300000]; vector<pair<int,int> > Q; int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n,m,x,y; cin>>n>>m; for(int i=1;i<=n;i++) { cin>>x>>y; Q.push_back({y,x}); } sort(Q.begin(),Q.end()); int suma=0; int wynikk=0; for(int i=0;i<n;i++) { suma+=Q[i].second; if(i+1<m) { wynik[i]=-suma+Q[i].second+2*Q[i].first; continue; } wynikk=max(wynikk,suma-2*Q[i].first+wynik[i-m+1]); wynik[i]=-suma+Q[i].second+2*Q[i].first; } cout<<wynikk; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...