| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 879821 | TAhmed33 | Akcija (COCI21_akcija) | C++98 | 5025 ms | 122960 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 25;
typedef long long ll;
int n; pair <ll, ll> a[MAXN];
vector <pair <ll, ll>> dp[2][MAXN];
bool comb (pair <ll, ll> &a, pair <ll, ll> &b) {
return a.first == b.first ? a.second < b.second : a.first > b.first;
}
int main () {
cin >> n; int k; cin >> k;
for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
sort(a + 1, a + n + 1, [] (pair <ll, ll> &x, pair <ll, ll> &y) { return x.second < y.second; });
for (int j = 0; j <= n + 1; j++) dp[(n + 1) & 1][j].push_back({0, 0});
for (int i = n; i >= 1; i--) {
for (int j = 0; j <= n; j++) {
dp[i & 1][j].clear();
if (j + 1 > a[i].second) {
dp[i & 1][j] = dp[(i + 1) & 1][j];
continue;
}
int p1 = 0, p2 = 0;
vector <pair <ll, ll>> &ret = dp[i & 1][j]; vector <pair <ll, ll>> &c1 = dp[(i + 1) & 1][j];
vector <pair <ll, ll>> &c2 = dp[(i + 1) & 1][j + 1];
while ((int)ret.size() < k && p1 < (int)c1.size() && p2 < (int)c2.size()) {
pair <ll, ll> x = c1[p1], y = {c2[p2].first + 1, c2[p2].second + a[i].first};
if (comb(x, y)) {
ret.push_back(x); p1++;
} else {
ret.push_back(y); p2++;
}
}
while ((int)ret.size() < k && p1 < (int)c1.size()) ret.push_back(c1[p1++]);
while ((int)ret.size() < k && p2 < (int)c2.size()) {
ret.push_back({c2[p2].first + 1, c2[p2].second + a[i].first}); p2++;
}
}
}
for (auto [x, y] : dp[1][0]) cout << x << " " << y << '\n';
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
