Submission #1169172

#TimeUsernameProblemLanguageResultExecution timeMemory
1169172userro1234324Jelly Flavours (IOI20_jelly)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "jelly.h"
using namespace std;
int n, X, Y:
int maxn = 2001;
int wynik;
// koszt oraz numer elementu
pair <int, int> elementy_a[maxn], elementy_b[maxn];
bool czy_jest_w_x[maxn];
int maksymalna_suma_y_do_wziecia;
int aktualna_suma_y;
int najlepsze_sumy_y[10001];
int ile_roznych_elementow;
int wartosc_a[maxn];
int wartosc_b[maxn];
int najlepsza_zabrana;
void dodaj_element_a(int i) {
    czy_jest_w_x[elementy_a[i].second] = true;
    maksymalna_suma_y_do_wziecia += elementy_b[elementy_a[i].second];
    for (int k = X; k >= elementy_a[i].first; k--) {
        najlepsze_sumy_y[k] = max(najlepsze_sumy_y[k], najlepsze_sumy_y[k - elementy_a[i].first] + wartosc_b[elementy_a[i].second]);
        najlepsza_zabrana = max(najlepsza_zabrana, najlepsze_sumy_y[k]);
    }
}
void sprawdz_drugi_ciag(int i) {
    ile_roznych_elementow = i;
    aktualna_suma_y = maksymalna_suma_y_do_wziecia;
    if (aktualna_suma_y - najlepsza_zabrana <= Y) wynik = max(wynik, ile_roznych_elementow);
    else return;
    for (int j = 1; j <= n; j++) {
        if (czy_jest_w_x[elementy_b[j].second]) continue;
        ile_roznych_elementow++;
        aktualna_suma_y += elementy_b[j].first;
        if (aktualna_suma_y - najlepsza_zabrana <= Y) wynik = max(wynik, ile_roznych_elementow);
        else return;
    }
}
void zrob_zadanie() {
    sprawdz_drugi_ciag(0);
    for (int i = 1; i <= n; i++) {
        dodaj_element_a(i);
        sprawdz_drugi_ciag(i);
    }
}
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
	int n = a.size();
	X = x; Y = y;
    for (int i = 1; i <= n; i++) {
        elementy_a[i] = {a[i - 1], i};
        elementy_b[i] = {b[i - 1], i};
        wartosc_a[i] = a[i - 1];
        wartosc_b[i] = b[i - 1];
    }
    sort(elementy_a + 1, elementy_a + n + 1);
    sort(elementy_b + 1, elementy_b + n + 1);
    zrob_zadanie();
    return wynik;
}

Compilation message (stderr)

jelly.cpp:4:12: error: expected initializer before ':' token
    4 | int n, X, Y:
      |            ^
jelly.cpp:8:28: error: 'maxn' was not declared in this scope
    8 | pair <int, int> elementy_a[maxn], elementy_b[maxn];
      |                            ^~~~
jelly.cpp:8:46: error: 'maxn' was not declared in this scope
    8 | pair <int, int> elementy_a[maxn], elementy_b[maxn];
      |                                              ^~~~
jelly.cpp:9:19: error: 'maxn' was not declared in this scope
    9 | bool czy_jest_w_x[maxn];
      |                   ^~~~
jelly.cpp:14:15: error: 'maxn' was not declared in this scope
   14 | int wartosc_a[maxn];
      |               ^~~~
jelly.cpp:15:15: error: 'maxn' was not declared in this scope
   15 | int wartosc_b[maxn];
      |               ^~~~
jelly.cpp: In function 'void dodaj_element_a(int)':
jelly.cpp:18:5: error: 'czy_jest_w_x' was not declared in this scope
   18 |     czy_jest_w_x[elementy_a[i].second] = true;
      |     ^~~~~~~~~~~~
jelly.cpp:18:18: error: 'elementy_a' was not declared in this scope
   18 |     czy_jest_w_x[elementy_a[i].second] = true;
      |                  ^~~~~~~~~~
jelly.cpp:19:37: error: 'elementy_b' was not declared in this scope
   19 |     maksymalna_suma_y_do_wziecia += elementy_b[elementy_a[i].second];
      |                                     ^~~~~~~~~~
jelly.cpp:21:100: error: 'wartosc_b' was not declared in this scope
   21 |         najlepsze_sumy_y[k] = max(najlepsze_sumy_y[k], najlepsze_sumy_y[k - elementy_a[i].first] + wartosc_b[elementy_a[i].second]);
      |                                                                                                    ^~~~~~~~~
jelly.cpp: In function 'void sprawdz_drugi_ciag(int)':
jelly.cpp:28:48: error: 'Y' was not declared in this scope
   28 |     if (aktualna_suma_y - najlepsza_zabrana <= Y) wynik = max(wynik, ile_roznych_elementow);
      |                                                ^
jelly.cpp:31:13: error: 'czy_jest_w_x' was not declared in this scope
   31 |         if (czy_jest_w_x[elementy_b[j].second]) continue;
      |             ^~~~~~~~~~~~
jelly.cpp:31:26: error: 'elementy_b' was not declared in this scope
   31 |         if (czy_jest_w_x[elementy_b[j].second]) continue;
      |                          ^~~~~~~~~~
jelly.cpp:33:28: error: 'elementy_b' was not declared in this scope
   33 |         aktualna_suma_y += elementy_b[j].first;
      |                            ^~~~~~~~~~
jelly.cpp:34:52: error: 'Y' was not declared in this scope
   34 |         if (aktualna_suma_y - najlepsza_zabrana <= Y) wynik = max(wynik, ile_roznych_elementow);
      |                                                    ^
jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:47:16: error: 'Y' was not declared in this scope
   47 |         X = x; Y = y;
      |                ^
jelly.cpp:49:9: error: 'elementy_a' was not declared in this scope
   49 |         elementy_a[i] = {a[i - 1], i};
      |         ^~~~~~~~~~
jelly.cpp:50:9: error: 'elementy_b' was not declared in this scope
   50 |         elementy_b[i] = {b[i - 1], i};
      |         ^~~~~~~~~~
jelly.cpp:51:9: error: 'wartosc_a' was not declared in this scope
   51 |         wartosc_a[i] = a[i - 1];
      |         ^~~~~~~~~
jelly.cpp:52:9: error: 'wartosc_b' was not declared in this scope
   52 |         wartosc_b[i] = b[i - 1];
      |         ^~~~~~~~~
jelly.cpp:54:10: error: 'elementy_a' was not declared in this scope
   54 |     sort(elementy_a + 1, elementy_a + n + 1);
      |          ^~~~~~~~~~
jelly.cpp:55:10: error: 'elementy_b' was not declared in this scope
   55 |     sort(elementy_b + 1, elementy_b + n + 1);
      |          ^~~~~~~~~~