Submission #630057

# Submission time Handle Problem Language Result Execution time Memory
630057 2022-08-15T15:18:55 Z garam1732 Catfish Farm (IOI22_fish) C++17
100 / 100
397 ms 61056 KB
#include "fish.h"

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

const int MAXN = 100100;
typedef long long ll;
typedef pair<int, int> pi;

vector<pi> c[MAXN];
vector<int> fish[MAXN];
vector<ll> sum[MAXN], dp[MAXN][3], a[4];

//        a[0][0] = dp[i][0][2] + sum[i+1][0];
//        a[0][1] = LLONG_MIN;
//        a[0][2] = dp[i-1][0][2];
//        a[0][3] = dp[i-1][0][2] + sum[i][0];
//        for(int j = 1; j <= N; j++) {
//            a[j][0] = max(a[j-1][0], dp[i][j][2] + sum[i+1][j]);
//            a[j][1] = max(a[j-1][1], dp[i][j][0] - sum[i][j]);
//            a[j][2] = max(a[j-1][2], dp[i-1][j][2]);
//            a[j][3] = max(a[j-1][3], dp[i-1][j][2] + sum[i][j]);
//        }
//
//        b[N][0] = dp[i][N][2] + sum[i+1][N];
//        b[N][1] = dp[i][N][0] - sum[i][N];
//        b[N][2] = dp[i-1][N][2];
//        b[N][3] = dp[i-1][N][2] + sum[i][N];
//        for(int j = N-1; j >= 0; j--) {
//            b[j][0] = max(b[j+1][0], dp[i][j][2] + sum[i+1][j]);
//            b[j][1] = max(b[j+1][1], dp[i][j][0] - sum[i][j]);
//            b[j][2] = max(b[j+1][2], dp[i-1][j][2]);
//            b[j][3] = max(b[j+1][3], dp[i-1][j][2] + sum[i][j]);
//        }

void f(int i, int N) {
    int it2;
    if(i+1 < N) {
        it2 = upper_bound(c[i+1].begin(), c[i+1].end(), pi(*fish[i].rbegin(), INT_MAX)) - c[i+1].begin();
        a[0].push_back(dp[i][2][(int)fish[i].size()-1] + sum[i+1][it2]);
        for(int j = (int)fish[i].size()-2; j >= 0; j--) {
            it2 = upper_bound(c[i+1].begin(), c[i+1].end(), pi(fish[i][j], INT_MAX)) - c[i+1].begin();
            a[0].push_back(max(*a[0].rbegin(), dp[i][2][j] + sum[i+1][it2]));
        }

        reverse(a[0].begin(), a[0].end());
    }

    it2 = upper_bound(c[i].begin(), c[i].end(), pi(fish[i][0], INT_MAX)) - c[i].begin();
    a[1].push_back(dp[i][0][0] - sum[i][it2]);
    for(int j = 1; j < fish[i].size(); j++) {
        it2 = upper_bound(c[i].begin(), c[i].end(), pi(fish[i][j], INT_MAX)) - c[i].begin();
        a[1].push_back(max(*a[1].rbegin(), dp[i][0][j] - sum[i][it2]));
    }

    if(i) {
        a[2].push_back(dp[i-1][2][0]);
        for(int j = 1; j < fish[i-1].size(); j++) {
            a[2].push_back(max(*a[2].rbegin(), dp[i-1][2][j]));
        }

        it2 = upper_bound(c[i].begin(), c[i].end(), pi(*fish[i-1].rbegin(), INT_MAX)) - c[i].begin();
        a[3].push_back(dp[i-1][2][(int)fish[i-1].size()-1] + sum[i][it2]);
        for(int j = (int)fish[i-1].size()-2; j >= 0; j--) {
            it2 = upper_bound(c[i].begin(), c[i].end(), pi(fish[i-1][j], INT_MAX)) - c[i].begin();
            a[3].push_back(max(*a[3].rbegin(), dp[i-1][2][j] + sum[i][it2]));
        }
        reverse(a[3].begin(), a[3].end());
    }
}

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
    for(int i = 0; i < M; i++) {
        c[X[i]].push_back(pi(Y[i]+1, W[i]));
    }

    for(int i = 0; i < N; i++) sort(c[i].begin(), c[i].end());
    for(int i = 0; i < N; i++) {
        fish[i].push_back(0);
        if(i) for(pi j : c[i-1]) fish[i].push_back(j.first);
        if(i+1 < N) for(pi j : c[i+1]) fish[i].push_back(j.first);

        sort(fish[i].begin(), fish[i].end());
        fish[i].erase(unique(fish[i].begin(), fish[i].end()), fish[i].end());
    }

    for(int i = 0; i < N; i++) {
        sum[i].push_back(0);
        for(pi t : c[i]) sum[i].push_back(*sum[i].rbegin()+t.second);
    }

//    for(int i = 0; i < N; i++)
//        for(pi t : c[i]) cout<<t.first<<" "<<t.second<<" ";
//    cout<<endl;
//    for(int i = 0; i < N; i++) {
//        for(int t : fish[i]) cout<<t<<" ";
//        cout<<endl;
//    }
//    cout<<endl;
//    for(int i = 0; i < N; i++) {
//        for(int t : sum[i]) cout<<t<<" ";
//        cout<<endl;
//    }
//    cout<<endl;

//    for(int j = 0; j <= N; j++) {
//        for(int k = j; k <= N; k++) {
//            dp[2][j][1] = max(dp[2][j][1], sum[2][k] - sum[2][j]);
//        }
//        for(int k = 0; k < j; k++) {
//            dp[2][j][0] = max(dp[2][j][0], sum[1][j] - sum[1][k]);
//        }
//
//        dp[2][j][2] = max(dp[2][j][0], dp[2][j][1]);
//    }

//    for(int j = 0; j <= N; j++) {
//        update(1, 0, N, j, dp[2][j][2] + sum[3][j], 0);
//        update(1, 0, N, j, dp[2][j][0] - sum[2][j], 1);
//        update(1, 0, N, j, dp[1][j][2], 2);
//        update(1, 0, N, j, dp[1][j][2] + sum[2][j], 3);
//    }
//    a[0][1] = LLONG_MIN;
//    a[0][2] = dp[1][0][2];
//    for(int j = 1; j <= N; j++) {
//        a[j][1] = max(a[j-1][1], dp[2][j][0] - sum[2][j]);
//        a[j][2] = max(a[j-1][2], dp[1][j][2]);
//    }
//
//    a[N][0] = dp[2][N][2] + sum[3][N];
//    a[N][3] = dp[1][N][2] + sum[2][N];
//    for(int j = N-1; j >= 0; j--) {
//        a[j][0] = max(a[j+1][0], dp[2][j][2] + sum[3][j]);
//        a[j][3] = max(a[j+1][3], dp[1][j][2] + sum[2][j]);
//    }
    for(int t : fish[0]) for(int j = 0; j < 3; j++) dp[0][j].push_back(0);

    f(0, N);

    int it1, it2;
    for(int i = 1; i < N; i++) {
        for(int k = 0; k < 3; k++) dp[i][k].resize(fish[i].size());
        for(int j = 0; j < fish[i].size(); j++) {
//            for(int k = j; k <= N; k++) {
//                //dp[i][j][1] = max(dp[i][j][1], dp[i-1][k][2] + sum[i][k] - sum[i][j]);
//                //if(i==N&&j==N-1)cout<<dp[i][j]<<" ";
//            }
            //dp[i][j][1] = solve(1, 0, N, j, N, 0) - sum[i][j];
            int v = fish[i][j];
            it1 = lower_bound(fish[i-1].begin(), fish[i-1].end(), v) - fish[i-1].begin();
            it2 = upper_bound(c[i].begin(), c[i].end(), pi(v, INT_MAX)) - c[i].begin();
            if(it1 < fish[i-1].size()) dp[i][1][j] = a[0][it1] - sum[i][it2];
            //cout<<endl;
//            for(int k = 1; k < j; k++) {
//                dp[i][j][0] = max(dp[i][j][0], dp[i-1][k][0] + sum[i-1][j] - sum[i-1][k]);
//                if(i==N&&j==N-1) cout<<dp[i][j]<<" ";
//            }
            //dp[i][j][0] = solve(1, 0, N, 1, j-1, 1) + sum[i-1][j];
            dp[i][0][j] = 0;

            //it1 = upper_bound(fish[i-1].begin(), fish[i-1].end(), j) - fish[i-1].begin();
            it2 = upper_bound(c[i-1].begin(), c[i-1].end(), pi(v, INT_MAX)) - c[i-1].begin();
            if(it1) dp[i][0][j] = a[1][it1-1] + sum[i-1][it2];
            //cout<<endl;
            //for(int k = 0; k <= N; k++) {
                //dp[i][j][0] = max(dp[i][j][0], dp[i-2][k][2] + sum[i-1][max(k, j)]);
                //if(i==N&&j==N-1) cout<<dp[i][j]<<" ";
            //}
            //dp[i][j][0] = max(dp[i][j][0], solve(1, 0, N, 0, j, 2) + sum[i-1][j]);
            if(i > 1) {
                it1 = upper_bound(fish[i-2].begin(), fish[i-2].end(), v) - fish[i-2].begin();
                if(it1) dp[i][0][j] = max(dp[i][0][j], a[2][it1-1] + sum[i-1][it2]);
                //dp[i][j][0] = max(dp[i][j][0], solve(1, 0, N, j+1, N, 3));
                //it1 = lower_bound(fish[i-2].begin(), fish[i-2].end(), j) - fish[i-2].begin();
                if(it1 < fish[i-2].size()) dp[i][0][j] = max(dp[i][0][j], a[3][it1]);
            }

            dp[i][2][j] = max(dp[i][0][j], dp[i][1][j]);
//            cout<<i<<" "<<j<<endl;
//            for(int t = 0; t<3;t++)cout<<dp[i][t][j]<<" ";
//            cout<<endl;
        }

        for(int k = 0; k < 4; k++) a[k].clear();

        f(i, N);


    }

//    for(int i = 1; i <= N; i++) {
//        for(int j  =0; j <= N; j++) cout<<dp[i][j]<<" ";
//        cout<<endl;
//    }

    long long ans = 0;
    for(int j = 0; j < fish[N-1].size(); j++) ans = max(ans, dp[N-1][2][j]);
    return ans;
}

Compilation message

fish.cpp: In function 'void f(int, int)':
fish.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int j = 1; j < fish[i].size(); j++) {
      |                    ~~^~~~~~~~~~~~~~~~
fish.cpp:62:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int j = 1; j < fish[i-1].size(); j++) {
      |                        ~~^~~~~~~~~~~~~~~~~~
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:141:13: warning: unused variable 't' [-Wunused-variable]
  141 |     for(int t : fish[0]) for(int j = 0; j < 3; j++) dp[0][j].push_back(0);
      |             ^
fish.cpp:148:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  148 |         for(int j = 0; j < fish[i].size(); j++) {
      |                        ~~^~~~~~~~~~~~~~~~
fish.cpp:157:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  157 |             if(it1 < fish[i-1].size()) dp[i][1][j] = a[0][it1] - sum[i][it2];
      |                ~~~~^~~~~~~~~~~~~~~~~~
fish.cpp:180:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  180 |                 if(it1 < fish[i-2].size()) dp[i][0][j] = max(dp[i][0][j], a[3][it1]);
      |                    ~~~~^~~~~~~~~~~~~~~~~~
fish.cpp:202:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  202 |     for(int j = 0; j < fish[N-1].size(); j++) ans = max(ans, dp[N-1][2][j]);
      |                    ~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 81 ms 36360 KB Output is correct
2 Correct 93 ms 39812 KB Output is correct
3 Correct 42 ms 30040 KB Output is correct
4 Correct 41 ms 30044 KB Output is correct
5 Correct 267 ms 61056 KB Output is correct
6 Correct 275 ms 58984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14344 KB Output is correct
2 Correct 164 ms 44040 KB Output is correct
3 Correct 193 ms 49232 KB Output is correct
4 Correct 84 ms 36348 KB Output is correct
5 Correct 96 ms 39832 KB Output is correct
6 Correct 7 ms 14292 KB Output is correct
7 Correct 8 ms 14292 KB Output is correct
8 Correct 8 ms 14292 KB Output is correct
9 Correct 9 ms 14292 KB Output is correct
10 Correct 43 ms 29948 KB Output is correct
11 Correct 40 ms 30028 KB Output is correct
12 Correct 102 ms 38652 KB Output is correct
13 Correct 147 ms 42516 KB Output is correct
14 Correct 96 ms 36264 KB Output is correct
15 Correct 116 ms 38792 KB Output is correct
16 Correct 97 ms 36344 KB Output is correct
17 Correct 106 ms 38588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 30004 KB Output is correct
2 Correct 40 ms 29940 KB Output is correct
3 Correct 70 ms 31324 KB Output is correct
4 Correct 65 ms 31924 KB Output is correct
5 Correct 110 ms 35500 KB Output is correct
6 Correct 115 ms 35536 KB Output is correct
7 Correct 110 ms 35472 KB Output is correct
8 Correct 159 ms 35424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14292 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 7 ms 14292 KB Output is correct
4 Correct 7 ms 14292 KB Output is correct
5 Correct 7 ms 14292 KB Output is correct
6 Correct 9 ms 14292 KB Output is correct
7 Correct 7 ms 14292 KB Output is correct
8 Correct 8 ms 14292 KB Output is correct
9 Correct 9 ms 14412 KB Output is correct
10 Correct 10 ms 14540 KB Output is correct
11 Correct 8 ms 14420 KB Output is correct
12 Correct 9 ms 14420 KB Output is correct
13 Correct 7 ms 14420 KB Output is correct
14 Correct 9 ms 14420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14292 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 7 ms 14292 KB Output is correct
4 Correct 7 ms 14292 KB Output is correct
5 Correct 7 ms 14292 KB Output is correct
6 Correct 9 ms 14292 KB Output is correct
7 Correct 7 ms 14292 KB Output is correct
8 Correct 8 ms 14292 KB Output is correct
9 Correct 9 ms 14412 KB Output is correct
10 Correct 10 ms 14540 KB Output is correct
11 Correct 8 ms 14420 KB Output is correct
12 Correct 9 ms 14420 KB Output is correct
13 Correct 7 ms 14420 KB Output is correct
14 Correct 9 ms 14420 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 10 ms 14548 KB Output is correct
17 Correct 47 ms 18008 KB Output is correct
18 Correct 43 ms 18632 KB Output is correct
19 Correct 33 ms 18652 KB Output is correct
20 Correct 34 ms 18448 KB Output is correct
21 Correct 34 ms 18384 KB Output is correct
22 Correct 66 ms 22368 KB Output is correct
23 Correct 15 ms 15316 KB Output is correct
24 Correct 33 ms 17180 KB Output is correct
25 Correct 8 ms 14540 KB Output is correct
26 Correct 17 ms 15268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 14292 KB Output is correct
2 Correct 8 ms 14292 KB Output is correct
3 Correct 7 ms 14292 KB Output is correct
4 Correct 7 ms 14292 KB Output is correct
5 Correct 7 ms 14292 KB Output is correct
6 Correct 9 ms 14292 KB Output is correct
7 Correct 7 ms 14292 KB Output is correct
8 Correct 8 ms 14292 KB Output is correct
9 Correct 9 ms 14412 KB Output is correct
10 Correct 10 ms 14540 KB Output is correct
11 Correct 8 ms 14420 KB Output is correct
12 Correct 9 ms 14420 KB Output is correct
13 Correct 7 ms 14420 KB Output is correct
14 Correct 9 ms 14420 KB Output is correct
15 Correct 8 ms 14420 KB Output is correct
16 Correct 10 ms 14548 KB Output is correct
17 Correct 47 ms 18008 KB Output is correct
18 Correct 43 ms 18632 KB Output is correct
19 Correct 33 ms 18652 KB Output is correct
20 Correct 34 ms 18448 KB Output is correct
21 Correct 34 ms 18384 KB Output is correct
22 Correct 66 ms 22368 KB Output is correct
23 Correct 15 ms 15316 KB Output is correct
24 Correct 33 ms 17180 KB Output is correct
25 Correct 8 ms 14540 KB Output is correct
26 Correct 17 ms 15268 KB Output is correct
27 Correct 11 ms 15036 KB Output is correct
28 Correct 186 ms 34572 KB Output is correct
29 Correct 266 ms 42316 KB Output is correct
30 Correct 270 ms 44884 KB Output is correct
31 Correct 291 ms 44620 KB Output is correct
32 Correct 212 ms 42068 KB Output is correct
33 Correct 293 ms 44948 KB Output is correct
34 Correct 273 ms 44876 KB Output is correct
35 Correct 99 ms 26268 KB Output is correct
36 Correct 297 ms 45748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 30004 KB Output is correct
2 Correct 40 ms 29940 KB Output is correct
3 Correct 70 ms 31324 KB Output is correct
4 Correct 65 ms 31924 KB Output is correct
5 Correct 110 ms 35500 KB Output is correct
6 Correct 115 ms 35536 KB Output is correct
7 Correct 110 ms 35472 KB Output is correct
8 Correct 159 ms 35424 KB Output is correct
9 Correct 126 ms 35536 KB Output is correct
10 Correct 76 ms 27688 KB Output is correct
11 Correct 150 ms 40956 KB Output is correct
12 Correct 7 ms 14292 KB Output is correct
13 Correct 8 ms 14292 KB Output is correct
14 Correct 7 ms 14292 KB Output is correct
15 Correct 8 ms 14356 KB Output is correct
16 Correct 8 ms 14292 KB Output is correct
17 Correct 8 ms 14348 KB Output is correct
18 Correct 43 ms 29932 KB Output is correct
19 Correct 52 ms 29964 KB Output is correct
20 Correct 41 ms 29932 KB Output is correct
21 Correct 39 ms 29980 KB Output is correct
22 Correct 119 ms 36696 KB Output is correct
23 Correct 161 ms 45152 KB Output is correct
24 Correct 168 ms 45672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 36360 KB Output is correct
2 Correct 93 ms 39812 KB Output is correct
3 Correct 42 ms 30040 KB Output is correct
4 Correct 41 ms 30044 KB Output is correct
5 Correct 267 ms 61056 KB Output is correct
6 Correct 275 ms 58984 KB Output is correct
7 Correct 8 ms 14344 KB Output is correct
8 Correct 164 ms 44040 KB Output is correct
9 Correct 193 ms 49232 KB Output is correct
10 Correct 84 ms 36348 KB Output is correct
11 Correct 96 ms 39832 KB Output is correct
12 Correct 7 ms 14292 KB Output is correct
13 Correct 8 ms 14292 KB Output is correct
14 Correct 8 ms 14292 KB Output is correct
15 Correct 9 ms 14292 KB Output is correct
16 Correct 43 ms 29948 KB Output is correct
17 Correct 40 ms 30028 KB Output is correct
18 Correct 102 ms 38652 KB Output is correct
19 Correct 147 ms 42516 KB Output is correct
20 Correct 96 ms 36264 KB Output is correct
21 Correct 116 ms 38792 KB Output is correct
22 Correct 97 ms 36344 KB Output is correct
23 Correct 106 ms 38588 KB Output is correct
24 Correct 44 ms 30004 KB Output is correct
25 Correct 40 ms 29940 KB Output is correct
26 Correct 70 ms 31324 KB Output is correct
27 Correct 65 ms 31924 KB Output is correct
28 Correct 110 ms 35500 KB Output is correct
29 Correct 115 ms 35536 KB Output is correct
30 Correct 110 ms 35472 KB Output is correct
31 Correct 159 ms 35424 KB Output is correct
32 Correct 8 ms 14292 KB Output is correct
33 Correct 8 ms 14292 KB Output is correct
34 Correct 7 ms 14292 KB Output is correct
35 Correct 7 ms 14292 KB Output is correct
36 Correct 7 ms 14292 KB Output is correct
37 Correct 9 ms 14292 KB Output is correct
38 Correct 7 ms 14292 KB Output is correct
39 Correct 8 ms 14292 KB Output is correct
40 Correct 9 ms 14412 KB Output is correct
41 Correct 10 ms 14540 KB Output is correct
42 Correct 8 ms 14420 KB Output is correct
43 Correct 9 ms 14420 KB Output is correct
44 Correct 7 ms 14420 KB Output is correct
45 Correct 9 ms 14420 KB Output is correct
46 Correct 8 ms 14420 KB Output is correct
47 Correct 10 ms 14548 KB Output is correct
48 Correct 47 ms 18008 KB Output is correct
49 Correct 43 ms 18632 KB Output is correct
50 Correct 33 ms 18652 KB Output is correct
51 Correct 34 ms 18448 KB Output is correct
52 Correct 34 ms 18384 KB Output is correct
53 Correct 66 ms 22368 KB Output is correct
54 Correct 15 ms 15316 KB Output is correct
55 Correct 33 ms 17180 KB Output is correct
56 Correct 8 ms 14540 KB Output is correct
57 Correct 17 ms 15268 KB Output is correct
58 Correct 11 ms 15036 KB Output is correct
59 Correct 186 ms 34572 KB Output is correct
60 Correct 266 ms 42316 KB Output is correct
61 Correct 270 ms 44884 KB Output is correct
62 Correct 291 ms 44620 KB Output is correct
63 Correct 212 ms 42068 KB Output is correct
64 Correct 293 ms 44948 KB Output is correct
65 Correct 273 ms 44876 KB Output is correct
66 Correct 99 ms 26268 KB Output is correct
67 Correct 297 ms 45748 KB Output is correct
68 Correct 126 ms 35536 KB Output is correct
69 Correct 76 ms 27688 KB Output is correct
70 Correct 150 ms 40956 KB Output is correct
71 Correct 7 ms 14292 KB Output is correct
72 Correct 8 ms 14292 KB Output is correct
73 Correct 7 ms 14292 KB Output is correct
74 Correct 8 ms 14356 KB Output is correct
75 Correct 8 ms 14292 KB Output is correct
76 Correct 8 ms 14348 KB Output is correct
77 Correct 43 ms 29932 KB Output is correct
78 Correct 52 ms 29964 KB Output is correct
79 Correct 41 ms 29932 KB Output is correct
80 Correct 39 ms 29980 KB Output is correct
81 Correct 119 ms 36696 KB Output is correct
82 Correct 161 ms 45152 KB Output is correct
83 Correct 168 ms 45672 KB Output is correct
84 Correct 341 ms 58016 KB Output is correct
85 Correct 397 ms 59040 KB Output is correct
86 Correct 287 ms 55420 KB Output is correct
87 Correct 308 ms 56692 KB Output is correct
88 Correct 8 ms 14344 KB Output is correct
89 Correct 281 ms 56676 KB Output is correct
90 Correct 274 ms 57004 KB Output is correct
91 Correct 273 ms 54792 KB Output is correct