Submission #992218

# Submission time Handle Problem Language Result Execution time Memory
992218 2024-06-04T06:07:26 Z inventiontime Gym Badges (NOI22_gymbadges) C++17
42 / 100
479 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;

#define int ll
#define endl '\n' //comment for interactive
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define pb push_back
#define re resize
#define ff first
#define ss second

#define all(x) (x).begin(), (x).end()
#define all1(x) (x).begin()+1, (x).end()
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, n) for(int i = 1; i <= n; i++)

#define print(x) cout << #x << ": " << x << endl << flush

typedef long long ll;
typedef vector<int> vi;
typedef array<int, 2> ii;
typedef array<int, 3> ti;
typedef vector<ii> vii;
typedef vector<ti> vti;
typedef vector<vi> vvi;
typedef priority_queue<int> pq;

template<class T> bool ckmin(T&a, T b) { bool B = a > b; a = min(a, b); return B; }
template<class T> bool ckmax(T&a, T b) { bool B = a < b; a = max(a, b); return B; }

const int inf = 1e17;
const int maxn = 5005;

void solve() {

    int n; cin >> n;
    vti g(n+1);
    loop1(i, n) cin >> g[i][1]; // x
    loop1(i, n) cin >> g[i][2]; // l
    loop1(i, n) g[i][0] = g[i][1] + g[i][2];
    sort(all1(g));

    vvi dp(n+1, vi(n+1, inf));
    loop(i, n+1) loop(j, n+1) dp[i][j] = inf;
    loop(i, n+1) dp[i][0] = 0;
    loop1(i, n) {
        loop1(j, n) {
            if(dp[i-1][j-1] <= g[i][2])
                ckmin(dp[i][j], dp[i-1][j-1] + g[i][1]);
            ckmin(dp[i][j], dp[i-1][j]);
        }
    }
    int res = 0;
    loop1(i, n) if(dp[n][i] < inf) res = i;
    cout << res << endl;

}

signed main() {

    fast_io;

    int t = 1; //cin >> t;
    while(t--)
        solve();

    return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 356 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 479 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 356 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 107 ms 190292 KB Output is correct
22 Correct 113 ms 193104 KB Output is correct
23 Correct 110 ms 191740 KB Output is correct
24 Correct 110 ms 192340 KB Output is correct
25 Correct 112 ms 192084 KB Output is correct
26 Correct 110 ms 190032 KB Output is correct
27 Correct 118 ms 194632 KB Output is correct
28 Correct 107 ms 188756 KB Output is correct
29 Correct 111 ms 192620 KB Output is correct
30 Correct 112 ms 195876 KB Output is correct
31 Correct 119 ms 195268 KB Output is correct
32 Correct 194 ms 190044 KB Output is correct
33 Correct 118 ms 192852 KB Output is correct
34 Correct 127 ms 194640 KB Output is correct
35 Correct 122 ms 193876 KB Output is correct
36 Correct 122 ms 194900 KB Output is correct
37 Correct 123 ms 191060 KB Output is correct
38 Correct 123 ms 189868 KB Output is correct
39 Correct 122 ms 193252 KB Output is correct
40 Correct 127 ms 191060 KB Output is correct
41 Correct 122 ms 194884 KB Output is correct
42 Correct 132 ms 191056 KB Output is correct
43 Correct 129 ms 190856 KB Output is correct
44 Correct 135 ms 193412 KB Output is correct
45 Correct 128 ms 191828 KB Output is correct
46 Correct 121 ms 195664 KB Output is correct
47 Correct 125 ms 192544 KB Output is correct
48 Correct 133 ms 191824 KB Output is correct
49 Correct 125 ms 190288 KB Output is correct
50 Correct 126 ms 192596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 356 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 352 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Runtime error 479 ms 1048576 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -