Submission #443130

# Submission time Handle Problem Language Result Execution time Memory
443130 2021-07-09T18:43:27 Z definitelynotmee Jelly Flavours (IOI20_jelly) C++17
0 / 100
223 ms 90612 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){
        if(a[c] == a[d])
            return b[c] > b[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;
        int cur = order[i];
        for(int j = x; j >= 0; j--){
            dp[j] = min(dp[j] + b[cur], i >= a[cur] ? dp[j-a[cur]] : INF);
        }
        if(dp[x] > y)
            continue;
        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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 89664 KB 1st lines differ - on the 1st token, expected: '689', found: '1949'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 223 ms 88492 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 199 ms 90612 KB 1st lines differ - on the 1st token, expected: '154', found: '1091'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 1st lines differ - on the 1st token, expected: '8', found: '4'
2 Halted 0 ms 0 KB -