Submission #318238

# Submission time Handle Problem Language Result Execution time Memory
318238 2020-10-31T16:22:50 Z Vladth11 Jelly Flavours (IOI20_jelly) C++14
Compilation error
0 ms 0 KB
#include "jelly.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair <int,int> pii;

int dp[2001][10001];
int costb[2001];
int i;

struct ura {
    int first, second, poz;
};
ura elem[2001];

bool cmp(ura a, ura b) {
    return a.second < b.second;
}

bool cm(ura a, ura b) {

    return a.first < b.first;
}
int bad[2001];
int ord[2001];

int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
    int n = a.size();
    for(i = 0; i < n; i++)
        elem[i] = {a[i], b[i], i};
    sort(elem, elem + n, cm);
    dp[0][0] = 0;
    int maxim = 0;
    for(i = 0; i <= n; i++){
        for(j = 0; j <= x; j++)
                        dp[i][j] = 2e9;

    }
    for(i = 1; i <= n; i++) {
        costb[i] = 2e9;
        ord[i] = elem[i - 1].poz;
        for(int j = 0; j <= x; j++) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j] + elem[i - 1].second);
            if(j >= elem[i - 1].first)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - elem[i - 1].first]);
           // cout << dp[i][j] << " ";
            costb[i] = min(costb[i], dp[i][j]);
        }
       // cout << "\n";
    }
    sort(elem, elem + n, cmp);
    for(i = 0; i <= n; i++) {
        if(i > 0) {
            bad[ord[i]] = 1;
        }
        //cout << i << " ";
        int raman = y - costb[i], cnt = 0;
        if(raman < 0)
            continue;
       // cout << raman << " ";
        for(int j = 0; j < n; j++) {
            if(bad[elem[j].poz])
                continue;
            if(raman - elem[j].second < 0){
                break;
            }
            //cout << elem[j].second << "\n";
            cnt++;
            raman -= elem[j].second;
        }
        //cout << cnt + i << "\n";
        maxim = max(maxim, cnt + i);
    }
    return maxim;
}

Compilation message

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:34:13: error: 'j' was not declared in this scope
   34 |         for(j = 0; j <= x; j++)
      |             ^