# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
104728 | antimirage | Cake 3 (JOI19_cake3) | C++14 | 2 ms | 256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 2005;
int n, m;
long long ans;
pair <int, int> a[N];
main(){
cin >> n >> m;
for (int i = 1; i <= n; i++)
scanf("%d%d", &a[i].sc, &a[i].fr);
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i++){
long long sum = 0;
for (int j = i; j <= n; j++){
sum += a[j].sc;
if (j - i + 1 == m)
ans = max(ans, sum - (a[j].fr - a[i].fr) * 2);
}
}
cout << ans << endl;
}
/**
5 3
2 1
4 2
6 4
8 8
10 16
**/
컴파일 시 표준 에러 (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... |