| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1317769 | nagorn_ph | Jelly Flavours (IOI20_jelly) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "jelly.h"
using namespace std;
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = a.size();
reverse(a.begin(), a.end()); a.emplace_back(0); reverse(a.begin(), a.end());
reverse(b.begin(), b.end()); b.emplace_back(0); reverse(b.begin(), b.end());
vector <pair <int, int>> v;
for (int i = 1; i <= n; i++) {
v.emplace_back(a[i], b[i]);
}
sort(v.begin(), v.end());
int ans = 0;
bool visited[n + 1] = {0};
int idx = 0;
for (auto [l, r] : v) {
if (l <= r && x >= l) {
visited[idx] = true;
ans++;
x -= l;
}
idx++;
}
idx = 0;
for (auto [l, r] : v) {
if (!visited[idx]y >= r) {
ans++;
y -= r;
}
idx++;
}
return ans;
}
/*
sub 1-2 , 3: constraints , y = 0
dp[i][j][k] = max ans when we used i at a, j at b, checked up to k
answer is at dp[x][y][n]
sub 4: b is all equal
greedy stupid again
sub 5: a and b are same
*/
