제출 #1014470

#제출 시각아이디문제언어결과실행 시간메모리
1014470vjudge1Cake 3 (JOI19_cake3)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define int long long vector<pair<int,int>> cake; int ans; int dostuf(int pen){ ans=0; map<int,pair<int,int>>mp; for(auto[i,j]:cake) if(j>=pen) mp[i].first+=j-pen,mp[i].second++; if(mp.empty())return 0; int prv=mp.begin()->first; pair<int,int>mmin,now,bst; for(auto&[i,j]:mp) j.first-=2*i-2*prv,prv=i, now.first+=j.first,now.second+=j.second,mmin=min(mmin,now), bst=max(bst,{now.first-mmin.first,now.second-mmin.second}); ans=bst.first; return bst.second; } signed main(){ int n,m; cin>>n>>m; cake.resize(n); for(auto&[i,j]:cake) cin>>j>>i; int l=-1e9,r=1e9,res=0; while(l<=r){ int mid=l+r>>1; if(dostuf(mid)>=m) l=mid+1,res=mid; else r=mid-1; } dostuf(res); cout<<ans+res*m; }

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

cake3.cpp: In function 'int main()':
cake3.cpp:28:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   28 |         int mid=l+r>>1;
      |                 ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...