제출 #156996

#제출 시각아이디문제언어결과실행 시간메모리
156996HungAnhGoldIBO2020Cake 3 (JOI19_cake3)C++14
0 / 100
2 ms376 KiB
#include<iostream> #include<algorithm> #define int long long using namespace std; const int N=2e5+2; const int inf=1e18+2; pair<int,int> val[N],dep[N]; int sum[N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,i,j,k,ans=-inf,max1=-inf,m; cin>>n>>m; for(i=1;i<=n;i++){ cin>>val[i].first>>val[i].second; } sort(val+1,val+1+n,[&](pair<int,int> x,pair<int,int> y){ return x.second<y.second; }); for(i=1;i<=n;i++){ sum[i]=sum[i-1]+val[i].first; if(i>=m){ max1=max(max1,2*val[i-m+1].second+val[i-m+1].first); ans=max(ans,max1+sum[i]-sum[i-m+1]-2*val[i].second); // cout<<max1+sum[i]-sum[i-m+1]-2*val[i].second<<endl; } } cout<<ans; }

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

cake3.cpp: In function 'int main()':
cake3.cpp:12:10: warning: unused variable 'j' [-Wunused-variable]
  int n,i,j,k,ans=-inf,max1=-inf,m;
          ^
cake3.cpp:12:12: warning: unused variable 'k' [-Wunused-variable]
  int n,i,j,k,ans=-inf,max1=-inf,m;
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...