Submission #443104

# Submission time Handle Problem Language Result Execution time Memory
443104 2021-07-09T17:11:44 Z definitelynotmee Jelly Flavours (IOI20_jelly) C++17
0 / 100
158 ms 90576 KB
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const double EPS = 1e-7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6+1;



int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){
    
    int n = a.size();
    vector<int> order(n);
    iota(order.begin(),order.end(),0);
    sort(order.begin(),order.end(),[&](int c, int d){return a[c] < a[d];});

    vector<multiset<int>> v(n+1);
    for(int i = n-1; i >= 0; i--){
        v[i] = v[i+1];
        v[i].insert(b[order[i]]);
    }
    int resp = 0;
    int cury = y;
    for(int i : v[0]){
        if(i <= cury)
            cury-=i, resp++;
        else break;
    }
    vector<int> dp(x+1,0);

    for(int i = 0; i < n; i++){
        //cerr << i << endl;
        for(int j = x; j >= 0; j--){
            dp[j] = min(dp[j] + b[i], i >= a[i] ? dp[j-a[i]] : INF);
        }
        if(dp[x] > y)
            break;
        int curresp = i+1; 
        cury = y-dp[x];
        for(int j  : v[i+1]){
            if(j > cury)
                break;
            curresp++;
            cury-=j;
        }
        resp = max(resp,curresp);
    }
    return resp;
}

/*int main(){
    int n, x, y;
    cin >> n >> x>> y;

    vector<int> a(n),b(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        cin >> b[i];
    cout << "resp = " << find_maximum_unique(x,y,a,b) << '\n';
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 89672 KB 1st lines differ - on the 1st token, expected: '689', found: '643'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 157 ms 88488 KB 1st lines differ - on the 1st token, expected: '62', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 90576 KB 1st lines differ - on the 1st token, expected: '154', found: '49'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '5'
2 Halted 0 ms 0 KB -