제출 #956116

#제출 시각아이디문제언어결과실행 시간메모리
956116pccCake 3 (JOI19_cake3)C++17
5 / 100
5 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define int ll #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const int mxn = 110; pll arr[mxn]; int N,K; ll calc(ll l,ll r){ vector<ll> v; for(int i = l+1;i<r;i++)v.push_back(arr[i].sc); sort(v.rbegin(),v.rend()); ll re = arr[l].sc+arr[r].sc-arr[r].fs*2+arr[l].fs*2; for(int i = 0;i<K-2;i++)re += v[i]; return re; } main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>K; for(int i = 1;i<=N;i++)cin>>arr[i].sc>>arr[i].fs; sort(arr+1,arr+N+1); ll ans = -1e18; for(int i = 1;i<=N;i++){ for(int j = i+K-1;j<=N;j++)ans = max(ans,calc(i,j)); } cout<<ans<<'\n'; }

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

cake3.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...