Submission #196777

# Submission time Handle Problem Language Result Execution time Memory
196777 2020-01-17T04:57:52 Z rkm0959 Two Dishes (JOI19_dishes) C++14
100 / 100
6891 ms 300984 KB
#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long double ldb;
typedef long long int ll;
typedef unsigned long long int ull;
typedef complex<double> base;

// range update (addition)
// range update (replacement)
// range query (maximum)

ll N, M, ans, inf=2e18;
ll tree[4444444];
ll lazy_1[4444444];
ll lazy_2[4444444];
ll A[1111111], B[1111111];
ll PA[1111111], PB[1111111];
ll f[1111111], g[1111111];
ll S[1111111], T[1111111];
ll P[1111111], Q[1111111];
vector< pair<ll, ll> > upd[1111111];

void workdown(int index, int s, int e)
{
    if(s==e) return;
    if(lazy_1[index])
    {
        tree[index<<1]+=lazy_1[index];
        if(lazy_2[index<<1]!=-inf) lazy_2[index<<1]+=lazy_1[index];
        else lazy_1[index<<1]+=lazy_1[index];
        tree[index<<1|1]+=lazy_1[index];
        if(lazy_2[index<<1|1]!=-inf) lazy_2[index<<1|1]+=lazy_1[index];
        else lazy_1[index<<1|1]+=lazy_1[index];
        lazy_1[index]=0;
    }
    if(lazy_2[index]!=-inf)
    {
        tree[index<<1]=tree[index];
        lazy_1[index<<1]=0; lazy_2[index<<1]=lazy_2[index];
        tree[index<<1|1]=tree[index];
        lazy_1[index<<1|1]=0; lazy_2[index<<1|1]=lazy_2[index];
        lazy_2[index]=-inf;
    }
}

void update_add(int index, int s, int e, int l, int r, ll v)
{
    if(l>e || r<s) return;
    workdown(index, s, e);
    if(l<=s && e<=r)
    {
        lazy_1[index]+=v;
        tree[index]+=v;
        return;
    }
    int m=(s+e)>>1;
    update_add(index<<1, s, m, l, r, v);
    update_add(index<<1|1, m+1, e, l, r, v);
    tree[index]=max(tree[index<<1], tree[index<<1|1]);
}

void update_repl(int index, int s, int e, int l, int r, ll v)
{
    if(l>e || r<s) return;
    workdown(index, s, e);
    if(l<=s && e<=r)
    {
        lazy_2[index]=v;
        tree[index]=v;
        return;
    }
    int m=(s+e)>>1;
    update_repl(index<<1, s, m, l, r, v);
    update_repl(index<<1|1, m+1, e, l, r, v);
    tree[index]=max(tree[index<<1], tree[index<<1|1]);
}

ll query(int index, int s, int e, int loc)
{
    if(s>loc || e<loc) return -inf;
    workdown(index, s, e);
    if(s==loc && e==loc) return tree[index];
    int m=(s+e)>>1;
    if(loc<=m) return query(index<<1, s, m, loc);
    else return query(index<<1|1, m+1, e, loc);
}

ll find_larger(int index, int s, int e, ll v)
{
    workdown(index, s, e);
    if(tree[index]<v) return M+1;
    int m=(s+e)>>1; if(s==e) return m;
    if(tree[index<<1]>=v) return find_larger(index<<1, s, m, v);
    else return find_larger(index<<1|1, m+1, e, v);
}

int main(void)
{
    fio; ll i, j, v, loc; cin>>N>>M;
    for(i=0 ; i<=4444440 ; i++) lazy_2[i]=-inf;
    for(i=1 ; i<=N ; i++) cin>>A[i]>>S[i]>>P[i];
    for(i=1 ; i<=M ; i++) cin>>B[i]>>T[i]>>Q[i];
    for(i=1 ; i<=N ; i++) PA[i]=PA[i-1]+A[i];
    for(i=1 ; i<=M ; i++) PB[i]=PB[i-1]+B[i];
    for(i=1 ; i<=N ; i++)
    {
        if(PA[i]>S[i]) { f[i]=-1; continue; }
        j=upper_bound(PB+1, PB+M+1, S[i]-PA[i])-PB; f[i]=j-1; 
    }
    for(i=1 ; i<=M ; i++)
    {
        if(PB[i]>T[i]) { g[i]=-1; continue; }
        j=upper_bound(PA+1, PA+N+1, T[i]-PB[i])-PA; g[i]=j-1;
    }
    for(i=1 ; i<=N ; i++)
    {
        if(f[i]==-1) continue;
        upd[i].push_back(make_pair(f[i], P[i]));
    }
    for(i=1 ; i<=M ; i++)
    {
        if(g[i]==-1) continue; ans+=Q[i];
        upd[g[i]+1].push_back(make_pair(i-1, -Q[i]));
    }
    upd[N+1].push_back(make_pair(M-1, -inf));
    for(i=1 ; i<=N+1 ; i++) sort(upd[i].begin(), upd[i].end());
    for(i=1 ; i<=N+1 ; i++)
    {
        for(j=0 ; j<upd[i].size() ; j++)
            update_add(1, 0, M, 0, upd[i][j].first, upd[i][j].second);
        for(j=0 ; j<upd[i].size() ; j++)
        {
            v=query(1, 0, M, upd[i][j].first);
            loc=find_larger(1, 0, M, v+1); loc--;
            if(j+1<upd[i].size()) loc=min(loc, upd[i][j+1].first);
            else loc=min(loc, M);
            if(loc>=upd[i][j].first+1) update_repl(1, 0, M, upd[i][j].first+1, loc, v);
        }
    }
    ans+=query(1, 0, M, M);
    cout<<ans; return 0;
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:123:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(g[i]==-1) continue; ans+=Q[i];
         ^~
dishes.cpp:123:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
         if(g[i]==-1) continue; ans+=Q[i];
                                ^~~
dishes.cpp:130:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0 ; j<upd[i].size() ; j++)
                   ~^~~~~~~~~~~~~~
dishes.cpp:132:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0 ; j<upd[i].size() ; j++)
                   ~^~~~~~~~~~~~~~
dishes.cpp:136:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(j+1<upd[i].size()) loc=min(loc, upd[i][j+1].first);
                ~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 536 ms 108188 KB Output is correct
2 Correct 568 ms 109436 KB Output is correct
3 Correct 473 ms 108144 KB Output is correct
4 Correct 470 ms 101400 KB Output is correct
5 Correct 56 ms 61304 KB Output is correct
6 Correct 545 ms 108172 KB Output is correct
7 Correct 280 ms 86368 KB Output is correct
8 Correct 192 ms 82564 KB Output is correct
9 Correct 467 ms 109276 KB Output is correct
10 Correct 507 ms 102028 KB Output is correct
11 Correct 396 ms 102492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 61432 KB Output is correct
2 Correct 55 ms 61304 KB Output is correct
3 Correct 66 ms 61276 KB Output is correct
4 Correct 56 ms 61304 KB Output is correct
5 Correct 55 ms 61332 KB Output is correct
6 Correct 56 ms 61304 KB Output is correct
7 Correct 55 ms 61308 KB Output is correct
8 Correct 56 ms 61340 KB Output is correct
9 Correct 57 ms 61304 KB Output is correct
10 Correct 56 ms 61392 KB Output is correct
11 Correct 55 ms 61404 KB Output is correct
12 Correct 61 ms 61432 KB Output is correct
13 Correct 66 ms 61316 KB Output is correct
14 Correct 65 ms 61304 KB Output is correct
15 Correct 56 ms 61368 KB Output is correct
16 Correct 56 ms 61304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 61432 KB Output is correct
2 Correct 55 ms 61304 KB Output is correct
3 Correct 66 ms 61276 KB Output is correct
4 Correct 56 ms 61304 KB Output is correct
5 Correct 55 ms 61332 KB Output is correct
6 Correct 56 ms 61304 KB Output is correct
7 Correct 55 ms 61308 KB Output is correct
8 Correct 56 ms 61340 KB Output is correct
9 Correct 57 ms 61304 KB Output is correct
10 Correct 56 ms 61392 KB Output is correct
11 Correct 55 ms 61404 KB Output is correct
12 Correct 61 ms 61432 KB Output is correct
13 Correct 66 ms 61316 KB Output is correct
14 Correct 65 ms 61304 KB Output is correct
15 Correct 56 ms 61368 KB Output is correct
16 Correct 56 ms 61304 KB Output is correct
17 Correct 59 ms 61764 KB Output is correct
18 Correct 56 ms 61688 KB Output is correct
19 Correct 61 ms 61816 KB Output is correct
20 Correct 59 ms 61720 KB Output is correct
21 Correct 61 ms 61788 KB Output is correct
22 Correct 60 ms 61692 KB Output is correct
23 Correct 61 ms 61688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 61432 KB Output is correct
2 Correct 55 ms 61304 KB Output is correct
3 Correct 66 ms 61276 KB Output is correct
4 Correct 56 ms 61304 KB Output is correct
5 Correct 55 ms 61332 KB Output is correct
6 Correct 56 ms 61304 KB Output is correct
7 Correct 55 ms 61308 KB Output is correct
8 Correct 56 ms 61340 KB Output is correct
9 Correct 57 ms 61304 KB Output is correct
10 Correct 56 ms 61392 KB Output is correct
11 Correct 55 ms 61404 KB Output is correct
12 Correct 61 ms 61432 KB Output is correct
13 Correct 66 ms 61316 KB Output is correct
14 Correct 65 ms 61304 KB Output is correct
15 Correct 56 ms 61368 KB Output is correct
16 Correct 56 ms 61304 KB Output is correct
17 Correct 59 ms 61764 KB Output is correct
18 Correct 56 ms 61688 KB Output is correct
19 Correct 61 ms 61816 KB Output is correct
20 Correct 59 ms 61720 KB Output is correct
21 Correct 61 ms 61788 KB Output is correct
22 Correct 60 ms 61692 KB Output is correct
23 Correct 61 ms 61688 KB Output is correct
24 Correct 480 ms 103704 KB Output is correct
25 Correct 421 ms 102224 KB Output is correct
26 Correct 497 ms 103976 KB Output is correct
27 Correct 426 ms 103744 KB Output is correct
28 Correct 696 ms 105232 KB Output is correct
29 Correct 443 ms 106004 KB Output is correct
30 Correct 1068 ms 107488 KB Output is correct
31 Correct 282 ms 85920 KB Output is correct
32 Correct 176 ms 80720 KB Output is correct
33 Correct 638 ms 100988 KB Output is correct
34 Correct 815 ms 106420 KB Output is correct
35 Correct 1379 ms 101148 KB Output is correct
36 Correct 976 ms 101224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 61432 KB Output is correct
2 Correct 55 ms 61304 KB Output is correct
3 Correct 66 ms 61276 KB Output is correct
4 Correct 56 ms 61304 KB Output is correct
5 Correct 55 ms 61332 KB Output is correct
6 Correct 56 ms 61304 KB Output is correct
7 Correct 55 ms 61308 KB Output is correct
8 Correct 56 ms 61340 KB Output is correct
9 Correct 57 ms 61304 KB Output is correct
10 Correct 56 ms 61392 KB Output is correct
11 Correct 55 ms 61404 KB Output is correct
12 Correct 61 ms 61432 KB Output is correct
13 Correct 66 ms 61316 KB Output is correct
14 Correct 65 ms 61304 KB Output is correct
15 Correct 56 ms 61368 KB Output is correct
16 Correct 56 ms 61304 KB Output is correct
17 Correct 59 ms 61764 KB Output is correct
18 Correct 56 ms 61688 KB Output is correct
19 Correct 61 ms 61816 KB Output is correct
20 Correct 59 ms 61720 KB Output is correct
21 Correct 61 ms 61788 KB Output is correct
22 Correct 60 ms 61692 KB Output is correct
23 Correct 61 ms 61688 KB Output is correct
24 Correct 480 ms 103704 KB Output is correct
25 Correct 421 ms 102224 KB Output is correct
26 Correct 497 ms 103976 KB Output is correct
27 Correct 426 ms 103744 KB Output is correct
28 Correct 696 ms 105232 KB Output is correct
29 Correct 443 ms 106004 KB Output is correct
30 Correct 1068 ms 107488 KB Output is correct
31 Correct 282 ms 85920 KB Output is correct
32 Correct 176 ms 80720 KB Output is correct
33 Correct 638 ms 100988 KB Output is correct
34 Correct 815 ms 106420 KB Output is correct
35 Correct 1379 ms 101148 KB Output is correct
36 Correct 976 ms 101224 KB Output is correct
37 Correct 531 ms 106904 KB Output is correct
38 Correct 479 ms 106728 KB Output is correct
39 Correct 536 ms 105768 KB Output is correct
40 Correct 640 ms 105672 KB Output is correct
41 Correct 55 ms 61304 KB Output is correct
42 Correct 1105 ms 110704 KB Output is correct
43 Correct 668 ms 104000 KB Output is correct
44 Correct 857 ms 109248 KB Output is correct
45 Correct 1037 ms 104372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 61432 KB Output is correct
2 Correct 55 ms 61304 KB Output is correct
3 Correct 66 ms 61276 KB Output is correct
4 Correct 56 ms 61304 KB Output is correct
5 Correct 55 ms 61332 KB Output is correct
6 Correct 56 ms 61304 KB Output is correct
7 Correct 55 ms 61308 KB Output is correct
8 Correct 56 ms 61340 KB Output is correct
9 Correct 57 ms 61304 KB Output is correct
10 Correct 56 ms 61392 KB Output is correct
11 Correct 55 ms 61404 KB Output is correct
12 Correct 61 ms 61432 KB Output is correct
13 Correct 66 ms 61316 KB Output is correct
14 Correct 65 ms 61304 KB Output is correct
15 Correct 56 ms 61368 KB Output is correct
16 Correct 56 ms 61304 KB Output is correct
17 Correct 59 ms 61764 KB Output is correct
18 Correct 56 ms 61688 KB Output is correct
19 Correct 61 ms 61816 KB Output is correct
20 Correct 59 ms 61720 KB Output is correct
21 Correct 61 ms 61788 KB Output is correct
22 Correct 60 ms 61692 KB Output is correct
23 Correct 61 ms 61688 KB Output is correct
24 Correct 480 ms 103704 KB Output is correct
25 Correct 421 ms 102224 KB Output is correct
26 Correct 497 ms 103976 KB Output is correct
27 Correct 426 ms 103744 KB Output is correct
28 Correct 696 ms 105232 KB Output is correct
29 Correct 443 ms 106004 KB Output is correct
30 Correct 1068 ms 107488 KB Output is correct
31 Correct 282 ms 85920 KB Output is correct
32 Correct 176 ms 80720 KB Output is correct
33 Correct 638 ms 100988 KB Output is correct
34 Correct 815 ms 106420 KB Output is correct
35 Correct 1379 ms 101148 KB Output is correct
36 Correct 976 ms 101224 KB Output is correct
37 Correct 531 ms 106904 KB Output is correct
38 Correct 479 ms 106728 KB Output is correct
39 Correct 536 ms 105768 KB Output is correct
40 Correct 640 ms 105672 KB Output is correct
41 Correct 55 ms 61304 KB Output is correct
42 Correct 1105 ms 110704 KB Output is correct
43 Correct 668 ms 104000 KB Output is correct
44 Correct 857 ms 109248 KB Output is correct
45 Correct 1037 ms 104372 KB Output is correct
46 Correct 2577 ms 281716 KB Output is correct
47 Correct 2169 ms 281684 KB Output is correct
48 Correct 2551 ms 275796 KB Output is correct
49 Correct 3320 ms 276068 KB Output is correct
50 Correct 6801 ms 300984 KB Output is correct
51 Correct 3733 ms 264436 KB Output is correct
52 Correct 4795 ms 287156 KB Output is correct
53 Correct 6451 ms 267604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 536 ms 108188 KB Output is correct
2 Correct 568 ms 109436 KB Output is correct
3 Correct 473 ms 108144 KB Output is correct
4 Correct 470 ms 101400 KB Output is correct
5 Correct 56 ms 61304 KB Output is correct
6 Correct 545 ms 108172 KB Output is correct
7 Correct 280 ms 86368 KB Output is correct
8 Correct 192 ms 82564 KB Output is correct
9 Correct 467 ms 109276 KB Output is correct
10 Correct 507 ms 102028 KB Output is correct
11 Correct 396 ms 102492 KB Output is correct
12 Correct 58 ms 61432 KB Output is correct
13 Correct 55 ms 61304 KB Output is correct
14 Correct 66 ms 61276 KB Output is correct
15 Correct 56 ms 61304 KB Output is correct
16 Correct 55 ms 61332 KB Output is correct
17 Correct 56 ms 61304 KB Output is correct
18 Correct 55 ms 61308 KB Output is correct
19 Correct 56 ms 61340 KB Output is correct
20 Correct 57 ms 61304 KB Output is correct
21 Correct 56 ms 61392 KB Output is correct
22 Correct 55 ms 61404 KB Output is correct
23 Correct 61 ms 61432 KB Output is correct
24 Correct 66 ms 61316 KB Output is correct
25 Correct 65 ms 61304 KB Output is correct
26 Correct 56 ms 61368 KB Output is correct
27 Correct 56 ms 61304 KB Output is correct
28 Correct 59 ms 61764 KB Output is correct
29 Correct 56 ms 61688 KB Output is correct
30 Correct 61 ms 61816 KB Output is correct
31 Correct 59 ms 61720 KB Output is correct
32 Correct 61 ms 61788 KB Output is correct
33 Correct 60 ms 61692 KB Output is correct
34 Correct 61 ms 61688 KB Output is correct
35 Correct 480 ms 103704 KB Output is correct
36 Correct 421 ms 102224 KB Output is correct
37 Correct 497 ms 103976 KB Output is correct
38 Correct 426 ms 103744 KB Output is correct
39 Correct 696 ms 105232 KB Output is correct
40 Correct 443 ms 106004 KB Output is correct
41 Correct 1068 ms 107488 KB Output is correct
42 Correct 282 ms 85920 KB Output is correct
43 Correct 176 ms 80720 KB Output is correct
44 Correct 638 ms 100988 KB Output is correct
45 Correct 815 ms 106420 KB Output is correct
46 Correct 1379 ms 101148 KB Output is correct
47 Correct 976 ms 101224 KB Output is correct
48 Correct 531 ms 106904 KB Output is correct
49 Correct 479 ms 106728 KB Output is correct
50 Correct 536 ms 105768 KB Output is correct
51 Correct 640 ms 105672 KB Output is correct
52 Correct 55 ms 61304 KB Output is correct
53 Correct 1105 ms 110704 KB Output is correct
54 Correct 668 ms 104000 KB Output is correct
55 Correct 857 ms 109248 KB Output is correct
56 Correct 1037 ms 104372 KB Output is correct
57 Correct 510 ms 107316 KB Output is correct
58 Correct 503 ms 107232 KB Output is correct
59 Correct 650 ms 106704 KB Output is correct
60 Correct 540 ms 106588 KB Output is correct
61 Correct 1083 ms 107836 KB Output is correct
62 Correct 57 ms 61364 KB Output is correct
63 Correct 1112 ms 110672 KB Output is correct
64 Correct 668 ms 104056 KB Output is correct
65 Correct 904 ms 109204 KB Output is correct
66 Correct 1004 ms 104228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 536 ms 108188 KB Output is correct
2 Correct 568 ms 109436 KB Output is correct
3 Correct 473 ms 108144 KB Output is correct
4 Correct 470 ms 101400 KB Output is correct
5 Correct 56 ms 61304 KB Output is correct
6 Correct 545 ms 108172 KB Output is correct
7 Correct 280 ms 86368 KB Output is correct
8 Correct 192 ms 82564 KB Output is correct
9 Correct 467 ms 109276 KB Output is correct
10 Correct 507 ms 102028 KB Output is correct
11 Correct 396 ms 102492 KB Output is correct
12 Correct 58 ms 61432 KB Output is correct
13 Correct 55 ms 61304 KB Output is correct
14 Correct 66 ms 61276 KB Output is correct
15 Correct 56 ms 61304 KB Output is correct
16 Correct 55 ms 61332 KB Output is correct
17 Correct 56 ms 61304 KB Output is correct
18 Correct 55 ms 61308 KB Output is correct
19 Correct 56 ms 61340 KB Output is correct
20 Correct 57 ms 61304 KB Output is correct
21 Correct 56 ms 61392 KB Output is correct
22 Correct 55 ms 61404 KB Output is correct
23 Correct 61 ms 61432 KB Output is correct
24 Correct 66 ms 61316 KB Output is correct
25 Correct 65 ms 61304 KB Output is correct
26 Correct 56 ms 61368 KB Output is correct
27 Correct 56 ms 61304 KB Output is correct
28 Correct 59 ms 61764 KB Output is correct
29 Correct 56 ms 61688 KB Output is correct
30 Correct 61 ms 61816 KB Output is correct
31 Correct 59 ms 61720 KB Output is correct
32 Correct 61 ms 61788 KB Output is correct
33 Correct 60 ms 61692 KB Output is correct
34 Correct 61 ms 61688 KB Output is correct
35 Correct 480 ms 103704 KB Output is correct
36 Correct 421 ms 102224 KB Output is correct
37 Correct 497 ms 103976 KB Output is correct
38 Correct 426 ms 103744 KB Output is correct
39 Correct 696 ms 105232 KB Output is correct
40 Correct 443 ms 106004 KB Output is correct
41 Correct 1068 ms 107488 KB Output is correct
42 Correct 282 ms 85920 KB Output is correct
43 Correct 176 ms 80720 KB Output is correct
44 Correct 638 ms 100988 KB Output is correct
45 Correct 815 ms 106420 KB Output is correct
46 Correct 1379 ms 101148 KB Output is correct
47 Correct 976 ms 101224 KB Output is correct
48 Correct 531 ms 106904 KB Output is correct
49 Correct 479 ms 106728 KB Output is correct
50 Correct 536 ms 105768 KB Output is correct
51 Correct 640 ms 105672 KB Output is correct
52 Correct 55 ms 61304 KB Output is correct
53 Correct 1105 ms 110704 KB Output is correct
54 Correct 668 ms 104000 KB Output is correct
55 Correct 857 ms 109248 KB Output is correct
56 Correct 1037 ms 104372 KB Output is correct
57 Correct 2577 ms 281716 KB Output is correct
58 Correct 2169 ms 281684 KB Output is correct
59 Correct 2551 ms 275796 KB Output is correct
60 Correct 3320 ms 276068 KB Output is correct
61 Correct 6801 ms 300984 KB Output is correct
62 Correct 3733 ms 264436 KB Output is correct
63 Correct 4795 ms 287156 KB Output is correct
64 Correct 6451 ms 267604 KB Output is correct
65 Correct 510 ms 107316 KB Output is correct
66 Correct 503 ms 107232 KB Output is correct
67 Correct 650 ms 106704 KB Output is correct
68 Correct 540 ms 106588 KB Output is correct
69 Correct 1083 ms 107836 KB Output is correct
70 Correct 57 ms 61364 KB Output is correct
71 Correct 1112 ms 110672 KB Output is correct
72 Correct 668 ms 104056 KB Output is correct
73 Correct 904 ms 109204 KB Output is correct
74 Correct 1004 ms 104228 KB Output is correct
75 Correct 2458 ms 278600 KB Output is correct
76 Correct 2453 ms 283372 KB Output is correct
77 Correct 3312 ms 275096 KB Output is correct
78 Correct 2669 ms 278280 KB Output is correct
79 Correct 6891 ms 299828 KB Output is correct
80 Correct 3897 ms 265264 KB Output is correct
81 Correct 5038 ms 285752 KB Output is correct
82 Correct 6395 ms 268240 KB Output is correct
83 Correct 6412 ms 287372 KB Output is correct