Submission #757557

#TimeUsernameProblemLanguageResultExecution timeMemory
7575571binJelly Flavours (IOI20_jelly)C++14
35 / 100
48 ms15948 KiB
#include <bits/stdc++.h>
#include "jelly.h"
 
using namespace std;
 
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 1e6 + 5;
int dp[2003][1004], dp2[2003][1004];
vector<pair<int, int>> v;
 
int find_maximum_unique(int Amx, int Bmx, vector<int> a, vector<int> b) {
	int n = a.size(), ans = 0;
    for(int i = 0; i < n; i++) v.emplace_back(a[i], b[i]);
    sort(all(v));

    for(int i = 1; i <= n; i++){
        auto&[a, b] = v[i - 1];
        for(int j = Amx; j >= a; j--) dp[i][j] = min(dp[i - 1][j] + b, dp[i - 1][j - a]);
        for(int j = a - 1; j >= 0; j--) dp[i][j] = dp[i - 1][j] + b;
        if(dp[i][Amx] <= Bmx) ans = i;
    }
    
    for(int i = n; i; i--){
        auto&[a, b] = v[i - 1];
        for(int j = Bmx; j >= 0; j--){
            dp2[i][j] = dp2[i + 1][j];
            if(j >= b) dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - b] + 1);
        }
        if(dp[i - 1][Amx] <= Bmx) ans = max(ans, i - 1 + dp2[i][Bmx - dp[i - 1][Amx]]);
    }
    
	return ans;
}

/*
int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n, Amx, Bmx;
    cin >> n >> Amx >> Bmx;
    vector<int> a(n), b(n);
    for(auto&x : a) cin >> x;
    for(auto&x : b) cin >> x;
    cout << find_maximum_unique(Amx, Bmx, a, b);
    return 0;
}
*/
 
/*
3
2 3
2 1 4
2 3 2
 
5
6 12
5 1 5 6 3
3 5 4 6 7
*/

Compilation message (stderr)

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:18:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   18 |         auto&[a, b] = v[i - 1];
      |              ^
jelly.cpp:25:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |         auto&[a, b] = v[i - 1];
      |              ^
#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...