| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 203423 | theStaticMind | Cake 3 (JOI19_cake3) | C++14 | 4051 ms | 7540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
bool operator< (ii a, ii b){
return a.first < b.first || (a.first == b.first && a.second < b.second);
}
bool comp(ii a, ii b){
return a.first > b.first || (a.first == b.first && a.second > b.second);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);;
int n, m, ans = -INF;
cin >> n >> m;
vector<ii> arr(n);
for(int i = 0; i < n; i++) cin >> arr[i].second >> arr[i].first;
sort(all(arr));
for(int i = 0; i < n; i++){
multiset<ii> data;
int sum = arr[i].second;
vector<ii> temp;
for(int j = 1; j <= i; j++) temp.pb({arr[i - j].second, arr[i - j].first});
sort(all(temp), comp);
for(int j = 0; j < temp.size(); j++){
if(data.size() >= m - 1){
sum -= data.begin()->second;
data.erase(data.begin());
}
data.insert({temp[j].second, temp[j].first});
sum += temp[j].first;
if(data.size() == m - 1){
ans = max(ans, sum - 2 * (arr[i].first - data.begin()->first));
}
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
