Submission #625243

# Submission time Handle Problem Language Result Execution time Memory
625243 2022-08-09T16:56:33 Z Ooops_sorry Uplifting Excursion (BOI22_vault) C++14
100 / 100
2766 ms 4788 KB
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define ld double
#define ll long long

mt19937 rnd(51);

const int INF = 1e9, M = 5.1e5 + 10, N = 1e3 + 10;

vector<int> calc_dp(vector<pair<int, ll>> u, bool f, int n) {
    vector<int> dp(n);
    vector<pair<ll, ll>> upd;
    for (int i = 0; i < u.size(); i++) {
        ll t = 0;
        while ((1LL << (t + 1)) <= u[i].second) {
            t++;
        }
        for (int j = 0; j < t; j++) {
            upd.pb({u[i].first * (1LL << j), (1LL << j)});
        }
        upd.pb({u[i].first * (u[i].second - (1LL << t) + 1), (u[i].second - (1LL << t) + 1)});
    }
    if (f) {
        for (int i = 1; i < n; i++) dp[i] = -INF;
    } else {
        for (int i = 1; i < n; i++) dp[i] = INF;
    }
    for (auto to : upd) {
        if (to.first >= n) continue;
        if (f) {
            for (int j = n - to.first - 1; j >= 0; j--) {
                if (dp[j] != -INF) {
                    dp[j + to.first] = max(dp[j + to.first], dp[j] + (int)to.second);
                }
            }
        } else {
            for (int j = n - to.first - 1; j >= 0; j--) {
                if (dp[j] != INF) {
                    dp[j + to.first] = min(dp[j + to.first], dp[j] + (int)to.second);
                }
            }
        }
    }
    return dp;
}

ll solve_pos(ll m, ll L, vector<ll> pos, int need_const) {
    if (L < 0) {
        return -1;
    }
    ll sum = L, cnt = 0;
    vector<pair<int, ll>> u1, u2;
    for (ll i = 1; i <= m; i++) {
        if (i * pos[i] > sum) {
            ll can = sum / i;
            sum -= can * i;
            cnt += can;
            u1.pb({i, can});
            u2.pb({i, pos[i] - can});
            for (int j = i + 1; j <= m; j++) {
                u2.pb({j, pos[j]});
            }
            break;
        } else {
            sum -= i * pos[i];
            cnt += pos[i];
            u1.pb({i, pos[i]});
        }
    }
    if (sum == 0) {
        return cnt;
    } else {
        vector<int> dp1 = calc_dp(u1, 0, need_const), dp2 = calc_dp(u2, 1, need_const);
        ll mx = -1;
        for (int j = 0; j + sum < need_const; j++) {
            if (dp2[j + sum] >= 0 && dp1[j] != INF) {
                mx = max(mx, cnt + dp2[j + sum] - dp1[j]);
            }
        }
        return mx;
    }
}

ll solve_any(ll m, ll L, vector<ll> neg, vector<ll> pos) {
    ll sum_neg = 0, sum_pos = 0;
    vector<pair<int, ll>> u1, u2;
    for (int i = 1; i <= m; i++) {
        u1.pb({i, neg[i]});
        sum_neg += i * neg[i];
    }
    for (int i = 1; i <= m; i++) {
        u2.pb({i, pos[i]});
        sum_pos += i * pos[i];
    }
    if (L > sum_pos) return -1;
    vector<int> dp1 = calc_dp(u1, 1, M), dp2 = calc_dp(u2, 1, M);
    ll mx = -1;
    ll need_val = min(sum_neg, sum_pos - L);
    for (int j = -100; j <= 100; j++) {
        ll res = solve_pos(m, j + need_val, neg, N);
        ll res2 = solve_pos(m, L + (j + need_val), pos, N);
        if (res != -1 && res2 != -1) {
            mx = max(mx, res + res2);
        }
    }
    return mx;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll m, L;
    cin >> m >> L;
    ll zero = 0;
    vector<ll> neg, pos{0};
    for (int i = 0; i < 2 * m + 1; i++) {
        ll a;
        cin >> a;
        if (i < m) {
            neg.pb(a);
        } else if (i == m) {
            zero += a;
        } else {
            pos.pb(a);
        }
    }
    neg.pb(0);
    reverse(neg.begin(), neg.end());
    ll mx = 0;
    for (auto to : neg) {
        mx = max(mx, to);
    }
    ll res;
    if (mx == 0) {
        res = solve_pos(m, L, pos, M);
    } else {
        if (L < 0) {
            L = abs(L);
            swap(neg, pos);
        }
        res = solve_any(m, L, neg, pos);
    }
    if (res == -1) {
        cout << "impossible" << endl;
    } else {
        cout << zero + res << endl;
    }
    return 0;
}

Compilation message

vault.cpp: In function 'std::vector<int> calc_dp(std::vector<std::pair<int, long long int> >, bool, int)':
vault.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i = 0; i < u.size(); i++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4296 KB Output is correct
2 Correct 7 ms 4328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 307 ms 4244 KB Output is correct
7 Correct 150 ms 4328 KB Output is correct
8 Correct 295 ms 4400 KB Output is correct
9 Correct 353 ms 4368 KB Output is correct
10 Correct 28 ms 4252 KB Output is correct
11 Correct 28 ms 4256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4296 KB Output is correct
2 Correct 7 ms 4328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 307 ms 4244 KB Output is correct
7 Correct 150 ms 4328 KB Output is correct
8 Correct 295 ms 4400 KB Output is correct
9 Correct 353 ms 4368 KB Output is correct
10 Correct 28 ms 4252 KB Output is correct
11 Correct 28 ms 4256 KB Output is correct
12 Correct 12 ms 4308 KB Output is correct
13 Correct 7 ms 4308 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 363 ms 4244 KB Output is correct
18 Correct 225 ms 4328 KB Output is correct
19 Correct 343 ms 4244 KB Output is correct
20 Correct 357 ms 4340 KB Output is correct
21 Correct 27 ms 4252 KB Output is correct
22 Correct 54 ms 4316 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 645 ms 4360 KB Output is correct
25 Correct 397 ms 4352 KB Output is correct
26 Correct 794 ms 4276 KB Output is correct
27 Correct 881 ms 4272 KB Output is correct
28 Correct 50 ms 4252 KB Output is correct
29 Correct 63 ms 4264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 187 ms 4272 KB Output is correct
3 Correct 74 ms 4244 KB Output is correct
4 Correct 189 ms 4336 KB Output is correct
5 Correct 147 ms 4252 KB Output is correct
6 Correct 105 ms 4352 KB Output is correct
7 Correct 46 ms 4324 KB Output is correct
8 Correct 22 ms 4320 KB Output is correct
9 Correct 84 ms 4264 KB Output is correct
10 Correct 104 ms 4280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 187 ms 4272 KB Output is correct
3 Correct 74 ms 4244 KB Output is correct
4 Correct 189 ms 4336 KB Output is correct
5 Correct 147 ms 4252 KB Output is correct
6 Correct 105 ms 4352 KB Output is correct
7 Correct 46 ms 4324 KB Output is correct
8 Correct 22 ms 4320 KB Output is correct
9 Correct 84 ms 4264 KB Output is correct
10 Correct 104 ms 4280 KB Output is correct
11 Correct 7 ms 4308 KB Output is correct
12 Correct 7 ms 4308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 154 ms 4268 KB Output is correct
16 Correct 48 ms 4244 KB Output is correct
17 Correct 152 ms 4252 KB Output is correct
18 Correct 145 ms 4260 KB Output is correct
19 Correct 101 ms 4332 KB Output is correct
20 Correct 37 ms 4288 KB Output is correct
21 Correct 30 ms 4244 KB Output is correct
22 Correct 90 ms 4244 KB Output is correct
23 Correct 113 ms 4280 KB Output is correct
24 Correct 336 ms 4360 KB Output is correct
25 Correct 119 ms 4336 KB Output is correct
26 Correct 322 ms 4352 KB Output is correct
27 Correct 251 ms 4336 KB Output is correct
28 Correct 306 ms 4256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 187 ms 4272 KB Output is correct
3 Correct 74 ms 4244 KB Output is correct
4 Correct 189 ms 4336 KB Output is correct
5 Correct 147 ms 4252 KB Output is correct
6 Correct 105 ms 4352 KB Output is correct
7 Correct 46 ms 4324 KB Output is correct
8 Correct 22 ms 4320 KB Output is correct
9 Correct 84 ms 4264 KB Output is correct
10 Correct 104 ms 4280 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 139 ms 4276 KB Output is correct
13 Correct 46 ms 4240 KB Output is correct
14 Correct 163 ms 4336 KB Output is correct
15 Correct 126 ms 4268 KB Output is correct
16 Correct 93 ms 4328 KB Output is correct
17 Correct 32 ms 4256 KB Output is correct
18 Correct 30 ms 4264 KB Output is correct
19 Correct 68 ms 4244 KB Output is correct
20 Correct 90 ms 4256 KB Output is correct
21 Correct 28 ms 4260 KB Output is correct
22 Correct 31 ms 4296 KB Output is correct
23 Correct 189 ms 4268 KB Output is correct
24 Correct 105 ms 4264 KB Output is correct
25 Correct 196 ms 4268 KB Output is correct
26 Correct 219 ms 4260 KB Output is correct
27 Correct 195 ms 4300 KB Output is correct
28 Correct 176 ms 4288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4296 KB Output is correct
2 Correct 7 ms 4328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 307 ms 4244 KB Output is correct
7 Correct 150 ms 4328 KB Output is correct
8 Correct 295 ms 4400 KB Output is correct
9 Correct 353 ms 4368 KB Output is correct
10 Correct 28 ms 4252 KB Output is correct
11 Correct 28 ms 4256 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 187 ms 4272 KB Output is correct
14 Correct 74 ms 4244 KB Output is correct
15 Correct 189 ms 4336 KB Output is correct
16 Correct 147 ms 4252 KB Output is correct
17 Correct 105 ms 4352 KB Output is correct
18 Correct 46 ms 4324 KB Output is correct
19 Correct 22 ms 4320 KB Output is correct
20 Correct 84 ms 4264 KB Output is correct
21 Correct 104 ms 4280 KB Output is correct
22 Correct 7 ms 4308 KB Output is correct
23 Correct 7 ms 4308 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 154 ms 4268 KB Output is correct
27 Correct 48 ms 4244 KB Output is correct
28 Correct 152 ms 4252 KB Output is correct
29 Correct 145 ms 4260 KB Output is correct
30 Correct 101 ms 4332 KB Output is correct
31 Correct 37 ms 4288 KB Output is correct
32 Correct 30 ms 4244 KB Output is correct
33 Correct 90 ms 4244 KB Output is correct
34 Correct 113 ms 4280 KB Output is correct
35 Correct 336 ms 4360 KB Output is correct
36 Correct 119 ms 4336 KB Output is correct
37 Correct 322 ms 4352 KB Output is correct
38 Correct 251 ms 4336 KB Output is correct
39 Correct 306 ms 4256 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 139 ms 4276 KB Output is correct
42 Correct 46 ms 4240 KB Output is correct
43 Correct 163 ms 4336 KB Output is correct
44 Correct 126 ms 4268 KB Output is correct
45 Correct 93 ms 4328 KB Output is correct
46 Correct 32 ms 4256 KB Output is correct
47 Correct 30 ms 4264 KB Output is correct
48 Correct 68 ms 4244 KB Output is correct
49 Correct 90 ms 4256 KB Output is correct
50 Correct 28 ms 4260 KB Output is correct
51 Correct 31 ms 4296 KB Output is correct
52 Correct 189 ms 4268 KB Output is correct
53 Correct 105 ms 4264 KB Output is correct
54 Correct 196 ms 4268 KB Output is correct
55 Correct 219 ms 4260 KB Output is correct
56 Correct 195 ms 4300 KB Output is correct
57 Correct 176 ms 4288 KB Output is correct
58 Correct 6 ms 4308 KB Output is correct
59 Correct 12 ms 4296 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 1 ms 324 KB Output is correct
62 Correct 0 ms 212 KB Output is correct
63 Correct 287 ms 4328 KB Output is correct
64 Correct 147 ms 4268 KB Output is correct
65 Correct 316 ms 4376 KB Output is correct
66 Correct 323 ms 4300 KB Output is correct
67 Correct 31 ms 4320 KB Output is correct
68 Correct 29 ms 4300 KB Output is correct
69 Correct 125 ms 4268 KB Output is correct
70 Correct 45 ms 4248 KB Output is correct
71 Correct 144 ms 4264 KB Output is correct
72 Correct 122 ms 4332 KB Output is correct
73 Correct 86 ms 4308 KB Output is correct
74 Correct 26 ms 4308 KB Output is correct
75 Correct 23 ms 4256 KB Output is correct
76 Correct 56 ms 4252 KB Output is correct
77 Correct 82 ms 4256 KB Output is correct
78 Correct 317 ms 4300 KB Output is correct
79 Correct 121 ms 4336 KB Output is correct
80 Correct 296 ms 4268 KB Output is correct
81 Correct 258 ms 4340 KB Output is correct
82 Correct 309 ms 4256 KB Output is correct
83 Correct 180 ms 4272 KB Output is correct
84 Correct 109 ms 4268 KB Output is correct
85 Correct 199 ms 4272 KB Output is correct
86 Correct 214 ms 4252 KB Output is correct
87 Correct 200 ms 4348 KB Output is correct
88 Correct 198 ms 4352 KB Output is correct
89 Correct 440 ms 4284 KB Output is correct
90 Correct 558 ms 4360 KB Output is correct
91 Correct 447 ms 4428 KB Output is correct
92 Correct 489 ms 4392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 187 ms 4272 KB Output is correct
3 Correct 74 ms 4244 KB Output is correct
4 Correct 189 ms 4336 KB Output is correct
5 Correct 147 ms 4252 KB Output is correct
6 Correct 105 ms 4352 KB Output is correct
7 Correct 46 ms 4324 KB Output is correct
8 Correct 22 ms 4320 KB Output is correct
9 Correct 84 ms 4264 KB Output is correct
10 Correct 104 ms 4280 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 139 ms 4276 KB Output is correct
13 Correct 46 ms 4240 KB Output is correct
14 Correct 163 ms 4336 KB Output is correct
15 Correct 126 ms 4268 KB Output is correct
16 Correct 93 ms 4328 KB Output is correct
17 Correct 32 ms 4256 KB Output is correct
18 Correct 30 ms 4264 KB Output is correct
19 Correct 68 ms 4244 KB Output is correct
20 Correct 90 ms 4256 KB Output is correct
21 Correct 28 ms 4260 KB Output is correct
22 Correct 31 ms 4296 KB Output is correct
23 Correct 189 ms 4268 KB Output is correct
24 Correct 105 ms 4264 KB Output is correct
25 Correct 196 ms 4268 KB Output is correct
26 Correct 219 ms 4260 KB Output is correct
27 Correct 195 ms 4300 KB Output is correct
28 Correct 176 ms 4288 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 135 ms 4276 KB Output is correct
31 Correct 65 ms 4248 KB Output is correct
32 Correct 148 ms 4256 KB Output is correct
33 Correct 132 ms 4256 KB Output is correct
34 Correct 85 ms 4332 KB Output is correct
35 Correct 27 ms 4308 KB Output is correct
36 Correct 39 ms 4248 KB Output is correct
37 Correct 61 ms 4248 KB Output is correct
38 Correct 84 ms 4256 KB Output is correct
39 Correct 24 ms 4248 KB Output is correct
40 Correct 26 ms 4252 KB Output is correct
41 Correct 198 ms 4268 KB Output is correct
42 Correct 105 ms 4256 KB Output is correct
43 Correct 189 ms 4276 KB Output is correct
44 Correct 228 ms 4264 KB Output is correct
45 Correct 201 ms 4348 KB Output is correct
46 Correct 178 ms 4280 KB Output is correct
47 Correct 46 ms 4260 KB Output is correct
48 Correct 64 ms 4244 KB Output is correct
49 Correct 403 ms 4304 KB Output is correct
50 Correct 194 ms 4280 KB Output is correct
51 Correct 423 ms 4300 KB Output is correct
52 Correct 460 ms 4296 KB Output is correct
53 Correct 401 ms 4380 KB Output is correct
54 Correct 352 ms 4320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4296 KB Output is correct
2 Correct 7 ms 4328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 307 ms 4244 KB Output is correct
7 Correct 150 ms 4328 KB Output is correct
8 Correct 295 ms 4400 KB Output is correct
9 Correct 353 ms 4368 KB Output is correct
10 Correct 28 ms 4252 KB Output is correct
11 Correct 28 ms 4256 KB Output is correct
12 Correct 12 ms 4308 KB Output is correct
13 Correct 7 ms 4308 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 363 ms 4244 KB Output is correct
18 Correct 225 ms 4328 KB Output is correct
19 Correct 343 ms 4244 KB Output is correct
20 Correct 357 ms 4340 KB Output is correct
21 Correct 27 ms 4252 KB Output is correct
22 Correct 54 ms 4316 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 645 ms 4360 KB Output is correct
25 Correct 397 ms 4352 KB Output is correct
26 Correct 794 ms 4276 KB Output is correct
27 Correct 881 ms 4272 KB Output is correct
28 Correct 50 ms 4252 KB Output is correct
29 Correct 63 ms 4264 KB Output is correct
30 Correct 1 ms 324 KB Output is correct
31 Correct 187 ms 4272 KB Output is correct
32 Correct 74 ms 4244 KB Output is correct
33 Correct 189 ms 4336 KB Output is correct
34 Correct 147 ms 4252 KB Output is correct
35 Correct 105 ms 4352 KB Output is correct
36 Correct 46 ms 4324 KB Output is correct
37 Correct 22 ms 4320 KB Output is correct
38 Correct 84 ms 4264 KB Output is correct
39 Correct 104 ms 4280 KB Output is correct
40 Correct 7 ms 4308 KB Output is correct
41 Correct 7 ms 4308 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 154 ms 4268 KB Output is correct
45 Correct 48 ms 4244 KB Output is correct
46 Correct 152 ms 4252 KB Output is correct
47 Correct 145 ms 4260 KB Output is correct
48 Correct 101 ms 4332 KB Output is correct
49 Correct 37 ms 4288 KB Output is correct
50 Correct 30 ms 4244 KB Output is correct
51 Correct 90 ms 4244 KB Output is correct
52 Correct 113 ms 4280 KB Output is correct
53 Correct 336 ms 4360 KB Output is correct
54 Correct 119 ms 4336 KB Output is correct
55 Correct 322 ms 4352 KB Output is correct
56 Correct 251 ms 4336 KB Output is correct
57 Correct 306 ms 4256 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 139 ms 4276 KB Output is correct
60 Correct 46 ms 4240 KB Output is correct
61 Correct 163 ms 4336 KB Output is correct
62 Correct 126 ms 4268 KB Output is correct
63 Correct 93 ms 4328 KB Output is correct
64 Correct 32 ms 4256 KB Output is correct
65 Correct 30 ms 4264 KB Output is correct
66 Correct 68 ms 4244 KB Output is correct
67 Correct 90 ms 4256 KB Output is correct
68 Correct 28 ms 4260 KB Output is correct
69 Correct 31 ms 4296 KB Output is correct
70 Correct 189 ms 4268 KB Output is correct
71 Correct 105 ms 4264 KB Output is correct
72 Correct 196 ms 4268 KB Output is correct
73 Correct 219 ms 4260 KB Output is correct
74 Correct 195 ms 4300 KB Output is correct
75 Correct 176 ms 4288 KB Output is correct
76 Correct 6 ms 4308 KB Output is correct
77 Correct 12 ms 4296 KB Output is correct
78 Correct 0 ms 212 KB Output is correct
79 Correct 1 ms 324 KB Output is correct
80 Correct 0 ms 212 KB Output is correct
81 Correct 287 ms 4328 KB Output is correct
82 Correct 147 ms 4268 KB Output is correct
83 Correct 316 ms 4376 KB Output is correct
84 Correct 323 ms 4300 KB Output is correct
85 Correct 31 ms 4320 KB Output is correct
86 Correct 29 ms 4300 KB Output is correct
87 Correct 125 ms 4268 KB Output is correct
88 Correct 45 ms 4248 KB Output is correct
89 Correct 144 ms 4264 KB Output is correct
90 Correct 122 ms 4332 KB Output is correct
91 Correct 86 ms 4308 KB Output is correct
92 Correct 26 ms 4308 KB Output is correct
93 Correct 23 ms 4256 KB Output is correct
94 Correct 56 ms 4252 KB Output is correct
95 Correct 82 ms 4256 KB Output is correct
96 Correct 317 ms 4300 KB Output is correct
97 Correct 121 ms 4336 KB Output is correct
98 Correct 296 ms 4268 KB Output is correct
99 Correct 258 ms 4340 KB Output is correct
100 Correct 309 ms 4256 KB Output is correct
101 Correct 180 ms 4272 KB Output is correct
102 Correct 109 ms 4268 KB Output is correct
103 Correct 199 ms 4272 KB Output is correct
104 Correct 214 ms 4252 KB Output is correct
105 Correct 200 ms 4348 KB Output is correct
106 Correct 198 ms 4352 KB Output is correct
107 Correct 440 ms 4284 KB Output is correct
108 Correct 558 ms 4360 KB Output is correct
109 Correct 447 ms 4428 KB Output is correct
110 Correct 489 ms 4392 KB Output is correct
111 Correct 1 ms 212 KB Output is correct
112 Correct 135 ms 4276 KB Output is correct
113 Correct 65 ms 4248 KB Output is correct
114 Correct 148 ms 4256 KB Output is correct
115 Correct 132 ms 4256 KB Output is correct
116 Correct 85 ms 4332 KB Output is correct
117 Correct 27 ms 4308 KB Output is correct
118 Correct 39 ms 4248 KB Output is correct
119 Correct 61 ms 4248 KB Output is correct
120 Correct 84 ms 4256 KB Output is correct
121 Correct 24 ms 4248 KB Output is correct
122 Correct 26 ms 4252 KB Output is correct
123 Correct 198 ms 4268 KB Output is correct
124 Correct 105 ms 4256 KB Output is correct
125 Correct 189 ms 4276 KB Output is correct
126 Correct 228 ms 4264 KB Output is correct
127 Correct 201 ms 4348 KB Output is correct
128 Correct 178 ms 4280 KB Output is correct
129 Correct 46 ms 4260 KB Output is correct
130 Correct 64 ms 4244 KB Output is correct
131 Correct 403 ms 4304 KB Output is correct
132 Correct 194 ms 4280 KB Output is correct
133 Correct 423 ms 4300 KB Output is correct
134 Correct 460 ms 4296 KB Output is correct
135 Correct 401 ms 4380 KB Output is correct
136 Correct 352 ms 4320 KB Output is correct
137 Correct 7 ms 4308 KB Output is correct
138 Correct 6 ms 4308 KB Output is correct
139 Correct 1 ms 212 KB Output is correct
140 Correct 1 ms 212 KB Output is correct
141 Correct 1 ms 212 KB Output is correct
142 Correct 283 ms 4248 KB Output is correct
143 Correct 124 ms 4248 KB Output is correct
144 Correct 258 ms 4332 KB Output is correct
145 Correct 299 ms 4268 KB Output is correct
146 Correct 30 ms 4316 KB Output is correct
147 Correct 25 ms 4328 KB Output is correct
148 Correct 1 ms 212 KB Output is correct
149 Correct 567 ms 4432 KB Output is correct
150 Correct 253 ms 4352 KB Output is correct
151 Correct 704 ms 4364 KB Output is correct
152 Correct 679 ms 4404 KB Output is correct
153 Correct 41 ms 4300 KB Output is correct
154 Correct 43 ms 4256 KB Output is correct
155 Correct 121 ms 4272 KB Output is correct
156 Correct 42 ms 4304 KB Output is correct
157 Correct 129 ms 4268 KB Output is correct
158 Correct 113 ms 4256 KB Output is correct
159 Correct 81 ms 4340 KB Output is correct
160 Correct 26 ms 4308 KB Output is correct
161 Correct 21 ms 4292 KB Output is correct
162 Correct 54 ms 4324 KB Output is correct
163 Correct 81 ms 4264 KB Output is correct
164 Correct 166 ms 4300 KB Output is correct
165 Correct 98 ms 4268 KB Output is correct
166 Correct 171 ms 4272 KB Output is correct
167 Correct 206 ms 4256 KB Output is correct
168 Correct 180 ms 4308 KB Output is correct
169 Correct 169 ms 4284 KB Output is correct
170 Correct 288 ms 4480 KB Output is correct
171 Correct 108 ms 4416 KB Output is correct
172 Correct 265 ms 4384 KB Output is correct
173 Correct 224 ms 4340 KB Output is correct
174 Correct 261 ms 4260 KB Output is correct
175 Correct 401 ms 4480 KB Output is correct
176 Correct 478 ms 4428 KB Output is correct
177 Correct 412 ms 4268 KB Output is correct
178 Correct 441 ms 4276 KB Output is correct
179 Correct 346 ms 4428 KB Output is correct
180 Correct 168 ms 4288 KB Output is correct
181 Correct 391 ms 4300 KB Output is correct
182 Correct 416 ms 4296 KB Output is correct
183 Correct 361 ms 4392 KB Output is correct
184 Correct 304 ms 4300 KB Output is correct
185 Correct 867 ms 4392 KB Output is correct
186 Correct 950 ms 4432 KB Output is correct
187 Correct 845 ms 4524 KB Output is correct
188 Correct 820 ms 4572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 187 ms 4272 KB Output is correct
3 Correct 74 ms 4244 KB Output is correct
4 Correct 189 ms 4336 KB Output is correct
5 Correct 147 ms 4252 KB Output is correct
6 Correct 105 ms 4352 KB Output is correct
7 Correct 46 ms 4324 KB Output is correct
8 Correct 22 ms 4320 KB Output is correct
9 Correct 84 ms 4264 KB Output is correct
10 Correct 104 ms 4280 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 139 ms 4276 KB Output is correct
13 Correct 46 ms 4240 KB Output is correct
14 Correct 163 ms 4336 KB Output is correct
15 Correct 126 ms 4268 KB Output is correct
16 Correct 93 ms 4328 KB Output is correct
17 Correct 32 ms 4256 KB Output is correct
18 Correct 30 ms 4264 KB Output is correct
19 Correct 68 ms 4244 KB Output is correct
20 Correct 90 ms 4256 KB Output is correct
21 Correct 28 ms 4260 KB Output is correct
22 Correct 31 ms 4296 KB Output is correct
23 Correct 189 ms 4268 KB Output is correct
24 Correct 105 ms 4264 KB Output is correct
25 Correct 196 ms 4268 KB Output is correct
26 Correct 219 ms 4260 KB Output is correct
27 Correct 195 ms 4300 KB Output is correct
28 Correct 176 ms 4288 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 135 ms 4276 KB Output is correct
31 Correct 65 ms 4248 KB Output is correct
32 Correct 148 ms 4256 KB Output is correct
33 Correct 132 ms 4256 KB Output is correct
34 Correct 85 ms 4332 KB Output is correct
35 Correct 27 ms 4308 KB Output is correct
36 Correct 39 ms 4248 KB Output is correct
37 Correct 61 ms 4248 KB Output is correct
38 Correct 84 ms 4256 KB Output is correct
39 Correct 24 ms 4248 KB Output is correct
40 Correct 26 ms 4252 KB Output is correct
41 Correct 198 ms 4268 KB Output is correct
42 Correct 105 ms 4256 KB Output is correct
43 Correct 189 ms 4276 KB Output is correct
44 Correct 228 ms 4264 KB Output is correct
45 Correct 201 ms 4348 KB Output is correct
46 Correct 178 ms 4280 KB Output is correct
47 Correct 46 ms 4260 KB Output is correct
48 Correct 64 ms 4244 KB Output is correct
49 Correct 403 ms 4304 KB Output is correct
50 Correct 194 ms 4280 KB Output is correct
51 Correct 423 ms 4300 KB Output is correct
52 Correct 460 ms 4296 KB Output is correct
53 Correct 401 ms 4380 KB Output is correct
54 Correct 352 ms 4320 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 117 ms 4268 KB Output is correct
57 Correct 44 ms 4260 KB Output is correct
58 Correct 130 ms 4384 KB Output is correct
59 Correct 116 ms 4300 KB Output is correct
60 Correct 82 ms 4328 KB Output is correct
61 Correct 25 ms 4308 KB Output is correct
62 Correct 21 ms 4260 KB Output is correct
63 Correct 51 ms 4300 KB Output is correct
64 Correct 80 ms 4268 KB Output is correct
65 Correct 24 ms 4264 KB Output is correct
66 Correct 25 ms 4252 KB Output is correct
67 Correct 163 ms 4272 KB Output is correct
68 Correct 96 ms 4272 KB Output is correct
69 Correct 166 ms 4268 KB Output is correct
70 Correct 211 ms 4260 KB Output is correct
71 Correct 179 ms 4264 KB Output is correct
72 Correct 167 ms 4268 KB Output is correct
73 Correct 40 ms 4268 KB Output is correct
74 Correct 42 ms 4300 KB Output is correct
75 Correct 348 ms 4300 KB Output is correct
76 Correct 167 ms 4276 KB Output is correct
77 Correct 387 ms 4300 KB Output is correct
78 Correct 441 ms 4372 KB Output is correct
79 Correct 368 ms 4264 KB Output is correct
80 Correct 300 ms 4288 KB Output is correct
81 Correct 1167 ms 4456 KB Output is correct
82 Correct 569 ms 4364 KB Output is correct
83 Correct 1149 ms 4472 KB Output is correct
84 Correct 1279 ms 4500 KB Output is correct
85 Correct 112 ms 4280 KB Output is correct
86 Correct 115 ms 4276 KB Output is correct
87 Correct 1064 ms 4396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4296 KB Output is correct
2 Correct 7 ms 4328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 307 ms 4244 KB Output is correct
7 Correct 150 ms 4328 KB Output is correct
8 Correct 295 ms 4400 KB Output is correct
9 Correct 353 ms 4368 KB Output is correct
10 Correct 28 ms 4252 KB Output is correct
11 Correct 28 ms 4256 KB Output is correct
12 Correct 12 ms 4308 KB Output is correct
13 Correct 7 ms 4308 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 363 ms 4244 KB Output is correct
18 Correct 225 ms 4328 KB Output is correct
19 Correct 343 ms 4244 KB Output is correct
20 Correct 357 ms 4340 KB Output is correct
21 Correct 27 ms 4252 KB Output is correct
22 Correct 54 ms 4316 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 645 ms 4360 KB Output is correct
25 Correct 397 ms 4352 KB Output is correct
26 Correct 794 ms 4276 KB Output is correct
27 Correct 881 ms 4272 KB Output is correct
28 Correct 50 ms 4252 KB Output is correct
29 Correct 63 ms 4264 KB Output is correct
30 Correct 1 ms 324 KB Output is correct
31 Correct 187 ms 4272 KB Output is correct
32 Correct 74 ms 4244 KB Output is correct
33 Correct 189 ms 4336 KB Output is correct
34 Correct 147 ms 4252 KB Output is correct
35 Correct 105 ms 4352 KB Output is correct
36 Correct 46 ms 4324 KB Output is correct
37 Correct 22 ms 4320 KB Output is correct
38 Correct 84 ms 4264 KB Output is correct
39 Correct 104 ms 4280 KB Output is correct
40 Correct 7 ms 4308 KB Output is correct
41 Correct 7 ms 4308 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 154 ms 4268 KB Output is correct
45 Correct 48 ms 4244 KB Output is correct
46 Correct 152 ms 4252 KB Output is correct
47 Correct 145 ms 4260 KB Output is correct
48 Correct 101 ms 4332 KB Output is correct
49 Correct 37 ms 4288 KB Output is correct
50 Correct 30 ms 4244 KB Output is correct
51 Correct 90 ms 4244 KB Output is correct
52 Correct 113 ms 4280 KB Output is correct
53 Correct 336 ms 4360 KB Output is correct
54 Correct 119 ms 4336 KB Output is correct
55 Correct 322 ms 4352 KB Output is correct
56 Correct 251 ms 4336 KB Output is correct
57 Correct 306 ms 4256 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 139 ms 4276 KB Output is correct
60 Correct 46 ms 4240 KB Output is correct
61 Correct 163 ms 4336 KB Output is correct
62 Correct 126 ms 4268 KB Output is correct
63 Correct 93 ms 4328 KB Output is correct
64 Correct 32 ms 4256 KB Output is correct
65 Correct 30 ms 4264 KB Output is correct
66 Correct 68 ms 4244 KB Output is correct
67 Correct 90 ms 4256 KB Output is correct
68 Correct 28 ms 4260 KB Output is correct
69 Correct 31 ms 4296 KB Output is correct
70 Correct 189 ms 4268 KB Output is correct
71 Correct 105 ms 4264 KB Output is correct
72 Correct 196 ms 4268 KB Output is correct
73 Correct 219 ms 4260 KB Output is correct
74 Correct 195 ms 4300 KB Output is correct
75 Correct 176 ms 4288 KB Output is correct
76 Correct 6 ms 4308 KB Output is correct
77 Correct 12 ms 4296 KB Output is correct
78 Correct 0 ms 212 KB Output is correct
79 Correct 1 ms 324 KB Output is correct
80 Correct 0 ms 212 KB Output is correct
81 Correct 287 ms 4328 KB Output is correct
82 Correct 147 ms 4268 KB Output is correct
83 Correct 316 ms 4376 KB Output is correct
84 Correct 323 ms 4300 KB Output is correct
85 Correct 31 ms 4320 KB Output is correct
86 Correct 29 ms 4300 KB Output is correct
87 Correct 125 ms 4268 KB Output is correct
88 Correct 45 ms 4248 KB Output is correct
89 Correct 144 ms 4264 KB Output is correct
90 Correct 122 ms 4332 KB Output is correct
91 Correct 86 ms 4308 KB Output is correct
92 Correct 26 ms 4308 KB Output is correct
93 Correct 23 ms 4256 KB Output is correct
94 Correct 56 ms 4252 KB Output is correct
95 Correct 82 ms 4256 KB Output is correct
96 Correct 317 ms 4300 KB Output is correct
97 Correct 121 ms 4336 KB Output is correct
98 Correct 296 ms 4268 KB Output is correct
99 Correct 258 ms 4340 KB Output is correct
100 Correct 309 ms 4256 KB Output is correct
101 Correct 180 ms 4272 KB Output is correct
102 Correct 109 ms 4268 KB Output is correct
103 Correct 199 ms 4272 KB Output is correct
104 Correct 214 ms 4252 KB Output is correct
105 Correct 200 ms 4348 KB Output is correct
106 Correct 198 ms 4352 KB Output is correct
107 Correct 440 ms 4284 KB Output is correct
108 Correct 558 ms 4360 KB Output is correct
109 Correct 447 ms 4428 KB Output is correct
110 Correct 489 ms 4392 KB Output is correct
111 Correct 1 ms 212 KB Output is correct
112 Correct 135 ms 4276 KB Output is correct
113 Correct 65 ms 4248 KB Output is correct
114 Correct 148 ms 4256 KB Output is correct
115 Correct 132 ms 4256 KB Output is correct
116 Correct 85 ms 4332 KB Output is correct
117 Correct 27 ms 4308 KB Output is correct
118 Correct 39 ms 4248 KB Output is correct
119 Correct 61 ms 4248 KB Output is correct
120 Correct 84 ms 4256 KB Output is correct
121 Correct 24 ms 4248 KB Output is correct
122 Correct 26 ms 4252 KB Output is correct
123 Correct 198 ms 4268 KB Output is correct
124 Correct 105 ms 4256 KB Output is correct
125 Correct 189 ms 4276 KB Output is correct
126 Correct 228 ms 4264 KB Output is correct
127 Correct 201 ms 4348 KB Output is correct
128 Correct 178 ms 4280 KB Output is correct
129 Correct 46 ms 4260 KB Output is correct
130 Correct 64 ms 4244 KB Output is correct
131 Correct 403 ms 4304 KB Output is correct
132 Correct 194 ms 4280 KB Output is correct
133 Correct 423 ms 4300 KB Output is correct
134 Correct 460 ms 4296 KB Output is correct
135 Correct 401 ms 4380 KB Output is correct
136 Correct 352 ms 4320 KB Output is correct
137 Correct 7 ms 4308 KB Output is correct
138 Correct 6 ms 4308 KB Output is correct
139 Correct 1 ms 212 KB Output is correct
140 Correct 1 ms 212 KB Output is correct
141 Correct 1 ms 212 KB Output is correct
142 Correct 283 ms 4248 KB Output is correct
143 Correct 124 ms 4248 KB Output is correct
144 Correct 258 ms 4332 KB Output is correct
145 Correct 299 ms 4268 KB Output is correct
146 Correct 30 ms 4316 KB Output is correct
147 Correct 25 ms 4328 KB Output is correct
148 Correct 1 ms 212 KB Output is correct
149 Correct 567 ms 4432 KB Output is correct
150 Correct 253 ms 4352 KB Output is correct
151 Correct 704 ms 4364 KB Output is correct
152 Correct 679 ms 4404 KB Output is correct
153 Correct 41 ms 4300 KB Output is correct
154 Correct 43 ms 4256 KB Output is correct
155 Correct 121 ms 4272 KB Output is correct
156 Correct 42 ms 4304 KB Output is correct
157 Correct 129 ms 4268 KB Output is correct
158 Correct 113 ms 4256 KB Output is correct
159 Correct 81 ms 4340 KB Output is correct
160 Correct 26 ms 4308 KB Output is correct
161 Correct 21 ms 4292 KB Output is correct
162 Correct 54 ms 4324 KB Output is correct
163 Correct 81 ms 4264 KB Output is correct
164 Correct 166 ms 4300 KB Output is correct
165 Correct 98 ms 4268 KB Output is correct
166 Correct 171 ms 4272 KB Output is correct
167 Correct 206 ms 4256 KB Output is correct
168 Correct 180 ms 4308 KB Output is correct
169 Correct 169 ms 4284 KB Output is correct
170 Correct 288 ms 4480 KB Output is correct
171 Correct 108 ms 4416 KB Output is correct
172 Correct 265 ms 4384 KB Output is correct
173 Correct 224 ms 4340 KB Output is correct
174 Correct 261 ms 4260 KB Output is correct
175 Correct 401 ms 4480 KB Output is correct
176 Correct 478 ms 4428 KB Output is correct
177 Correct 412 ms 4268 KB Output is correct
178 Correct 441 ms 4276 KB Output is correct
179 Correct 346 ms 4428 KB Output is correct
180 Correct 168 ms 4288 KB Output is correct
181 Correct 391 ms 4300 KB Output is correct
182 Correct 416 ms 4296 KB Output is correct
183 Correct 361 ms 4392 KB Output is correct
184 Correct 304 ms 4300 KB Output is correct
185 Correct 867 ms 4392 KB Output is correct
186 Correct 950 ms 4432 KB Output is correct
187 Correct 845 ms 4524 KB Output is correct
188 Correct 820 ms 4572 KB Output is correct
189 Correct 1 ms 212 KB Output is correct
190 Correct 117 ms 4268 KB Output is correct
191 Correct 44 ms 4260 KB Output is correct
192 Correct 130 ms 4384 KB Output is correct
193 Correct 116 ms 4300 KB Output is correct
194 Correct 82 ms 4328 KB Output is correct
195 Correct 25 ms 4308 KB Output is correct
196 Correct 21 ms 4260 KB Output is correct
197 Correct 51 ms 4300 KB Output is correct
198 Correct 80 ms 4268 KB Output is correct
199 Correct 24 ms 4264 KB Output is correct
200 Correct 25 ms 4252 KB Output is correct
201 Correct 163 ms 4272 KB Output is correct
202 Correct 96 ms 4272 KB Output is correct
203 Correct 166 ms 4268 KB Output is correct
204 Correct 211 ms 4260 KB Output is correct
205 Correct 179 ms 4264 KB Output is correct
206 Correct 167 ms 4268 KB Output is correct
207 Correct 40 ms 4268 KB Output is correct
208 Correct 42 ms 4300 KB Output is correct
209 Correct 348 ms 4300 KB Output is correct
210 Correct 167 ms 4276 KB Output is correct
211 Correct 387 ms 4300 KB Output is correct
212 Correct 441 ms 4372 KB Output is correct
213 Correct 368 ms 4264 KB Output is correct
214 Correct 300 ms 4288 KB Output is correct
215 Correct 1167 ms 4456 KB Output is correct
216 Correct 569 ms 4364 KB Output is correct
217 Correct 1149 ms 4472 KB Output is correct
218 Correct 1279 ms 4500 KB Output is correct
219 Correct 112 ms 4280 KB Output is correct
220 Correct 115 ms 4276 KB Output is correct
221 Correct 1064 ms 4396 KB Output is correct
222 Correct 0 ms 212 KB Output is correct
223 Correct 116 ms 4300 KB Output is correct
224 Correct 41 ms 4248 KB Output is correct
225 Correct 128 ms 4284 KB Output is correct
226 Correct 145 ms 4336 KB Output is correct
227 Correct 85 ms 4324 KB Output is correct
228 Correct 26 ms 4260 KB Output is correct
229 Correct 20 ms 4260 KB Output is correct
230 Correct 53 ms 4252 KB Output is correct
231 Correct 79 ms 4268 KB Output is correct
232 Correct 24 ms 4256 KB Output is correct
233 Correct 25 ms 4260 KB Output is correct
234 Correct 168 ms 4300 KB Output is correct
235 Correct 101 ms 4268 KB Output is correct
236 Correct 167 ms 4300 KB Output is correct
237 Correct 207 ms 4344 KB Output is correct
238 Correct 178 ms 4300 KB Output is correct
239 Correct 167 ms 4272 KB Output is correct
240 Correct 41 ms 4256 KB Output is correct
241 Correct 49 ms 4256 KB Output is correct
242 Correct 348 ms 4300 KB Output is correct
243 Correct 167 ms 4300 KB Output is correct
244 Correct 385 ms 4276 KB Output is correct
245 Correct 410 ms 4308 KB Output is correct
246 Correct 355 ms 4392 KB Output is correct
247 Correct 302 ms 4320 KB Output is correct
248 Correct 6 ms 4308 KB Output is correct
249 Correct 6 ms 4308 KB Output is correct
250 Correct 1 ms 212 KB Output is correct
251 Correct 0 ms 212 KB Output is correct
252 Correct 251 ms 4400 KB Output is correct
253 Correct 126 ms 4300 KB Output is correct
254 Correct 257 ms 4376 KB Output is correct
255 Correct 301 ms 4404 KB Output is correct
256 Correct 1 ms 212 KB Output is correct
257 Correct 554 ms 4372 KB Output is correct
258 Correct 251 ms 4260 KB Output is correct
259 Correct 667 ms 4412 KB Output is correct
260 Correct 660 ms 4428 KB Output is correct
261 Correct 279 ms 4408 KB Output is correct
262 Correct 108 ms 4256 KB Output is correct
263 Correct 260 ms 4256 KB Output is correct
264 Correct 216 ms 4252 KB Output is correct
265 Correct 269 ms 4268 KB Output is correct
266 Correct 392 ms 4304 KB Output is correct
267 Correct 477 ms 4428 KB Output is correct
268 Correct 399 ms 4284 KB Output is correct
269 Correct 434 ms 4276 KB Output is correct
270 Correct 850 ms 4392 KB Output is correct
271 Correct 949 ms 4404 KB Output is correct
272 Correct 835 ms 4388 KB Output is correct
273 Correct 805 ms 4556 KB Output is correct
274 Correct 1152 ms 4448 KB Output is correct
275 Correct 570 ms 4368 KB Output is correct
276 Correct 1127 ms 4396 KB Output is correct
277 Correct 1274 ms 4500 KB Output is correct
278 Correct 117 ms 4292 KB Output is correct
279 Correct 113 ms 4296 KB Output is correct
280 Correct 1031 ms 4396 KB Output is correct
281 Correct 2543 ms 4776 KB Output is correct
282 Correct 2766 ms 4788 KB Output is correct
283 Correct 2552 ms 4764 KB Output is correct