제출 #1169043

#제출 시각아이디문제언어결과실행 시간메모리
1169043patgraJelly Flavours (IOI20_jelly)C++20
35 / 100
223 ms197868 KiB
#include <bits/stdc++.h>

#define rep(a,b,c) for(auto a = (b); a != (c); a++)
#define repD(a,b,c) for(auto a = (b); a != (c); a--)
#define repIn(a, b) for(auto& a : (b))
#define repIn2(a, b, c) for(auto& [a, b] : (c))

constexpr bool dbg = 1;
#define DEBUG if constexpr(dbg)
#define DC DEBUG std::cerr
#define eol std::endl

#define ll long long
#define pb push_back

using namespace std;

#include "jelly.h"
#include <vector>

int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
	int n = (int)a.size();
    if(y == 0) { // p3
        sort(a.begin(), a.end());
        int ans = 0;
        while(ans < n && x > a[ans]) x -= a[ans++];
        return ans;
    }
    bool podz4 = true;
    rep(i, 1, n) if(b[i] != b[i - 1]) { podz4 = false; break; }
    if(podz4) { // p4
        sort(a.begin(), a.end());
        int ans = 0;
        while(ans < n && x > a[ans]) x -= a[ans++];
        while(ans < n && y > b[0]) y -= b[0], ans++;
        return ans;
    }
    if(x <= 500 && y <= 500 && n <= 200) { // p1, p2
        int dp[201][501][501]; // i items, j remaining of x, k remaining of y
        repIn(i, dp) repIn(ii, i) repIn(iii, ii) iii = -1;
        dp[0][x][y] = 0;
        rep(i, 0, n) rep(j, 0, x + 1) rep(k, 0, y + 1) if(dp[i][j][k] != -1) {
            dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
            if(j >= a[i]) dp[i + 1][j - a[i]][k] = max(dp[i + 1][j - a[i]][k], dp[i][j][k] + 1);
            if(k >= b[i]) dp[i + 1][j][k - b[i]] = max(dp[i + 1][j][k - b[i]], dp[i][j][k] + 1);
        }
        int ans = 0;
        repIn(i, dp) repIn(ii, i) repIn(iii, ii) ans = max(ans, iii);
        return ans;
    }
    bool podz5 = true;
    rep(i, 0, n) if(a[i] != b[i]) { podz5 = false; break; }
    return 0;
    if(podz5) { // p5
    }
    // p6
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...