Submission #787261

# Submission time Handle Problem Language Result Execution time Memory
787261 2023-07-19T01:00:09 Z Ozy Gym Badges (NOI22_gymbadges) C++17
42 / 100
24 ms 852 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli>

#define MAX 5000
//para el arr
#define exp first
#define umbral second

lli n,cont,a,b;
pll arr[MAX+2],act,res[MAX+2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    rep(i,1,n) cin >> arr[i].first;
    rep(i,1,n) cin >> arr[i].second;
    sort(arr+1, arr+n+1);

    res[0] = {0,(1ll<<60)};
    cont = 0;
    rep(Q,1,n) {

        act = arr[Q];
        lli pos = -1;
        lli mejor = -1;
        lli MIN = (1ll<<60);
        repa(i,cont,0) {

            a = act.umbral - res[i].exp;
            if (a < 0) {
                if (act.exp > res[i].umbral) break;
                continue;
            }

            b = min(MIN,a);
            if (b > mejor) {
                mejor = b;
                pos = i+1;
            }

            MIN = min(MIN,res[i].umbral-act.exp);
            if (act.exp > res[i].umbral) break;

            //debugsl(a);
            //debugsl(b);
            //debug(MIN);
        }

        //debugsl(act.exp);
        //debugsl(act.umbral);
        //debug(pos);

        if (pos != -1) {
            cont++;
            pll cambio = {res[pos-1].exp + act.exp,(act.umbral - res[pos-1].exp)};
            rep(i,pos,cont) {
                res[i].exp += act.exp;
                res[i].umbral -= act.exp;
                swap(cambio,res[i]);
            }
        }

        //rep(i,1,cont) debugsl(res[i].exp);
        //cout << endl;
        //rep(i,1,cont) debugsl(res[i].umbral);
        //cout << endl;
    }

    cout << cont;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 460 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 436 KB Output is correct
26 Correct 3 ms 436 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 3 ms 464 KB Output is correct
31 Correct 5 ms 468 KB Output is correct
32 Correct 5 ms 428 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 5 ms 468 KB Output is correct
35 Correct 5 ms 468 KB Output is correct
36 Correct 10 ms 468 KB Output is correct
37 Correct 9 ms 588 KB Output is correct
38 Correct 10 ms 468 KB Output is correct
39 Correct 10 ms 468 KB Output is correct
40 Correct 9 ms 464 KB Output is correct
41 Correct 16 ms 464 KB Output is correct
42 Correct 16 ms 464 KB Output is correct
43 Correct 17 ms 468 KB Output is correct
44 Correct 15 ms 520 KB Output is correct
45 Correct 16 ms 540 KB Output is correct
46 Correct 20 ms 468 KB Output is correct
47 Correct 19 ms 540 KB Output is correct
48 Correct 21 ms 532 KB Output is correct
49 Correct 22 ms 556 KB Output is correct
50 Correct 24 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Runtime error 1 ms 852 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -