Submission #1059839

# Submission time Handle Problem Language Result Execution time Memory
1059839 2024-08-15T08:38:40 Z tolbi Closing Time (IOI23_closing) C++17
9 / 100
1000 ms 9700 KB
#include "closing.h"

#include <bits/stdc++.h>
using namespace std;

int max_score(int N, int X, int Y, long long K,
  std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    vector<long long> dp1(N);
    vector<long long> dp2(N);
    vector<long long> dp3(N);
    long long cur = 0;
    for (int i = X-1; i >= 0; i--){
        cur+=W[i];
        dp1[i]=cur;
    }
    cur=0;
    for (int i = X+1; i < N; i++){
        cur+=W[i-1];
        dp1[i]=cur;
    }

    cur = 0;
    for (int i = Y-1; i >= 0; i--){
        cur+=W[i];
        dp2[i]=cur;
    }
    cur=0;
    for (int i = Y+1; i < N; i++){
        cur+=W[i-1];
        dp2[i]=cur;
    }
    for (int i = 0; i < N; i++){
        dp3[i]=max(dp1[i],dp2[i]);
        if (i) dp3[i]+=dp3[i-1];
        if (i) dp2[i]+=dp2[i-1];
        if (i) dp1[i]+=dp1[i-1];
    }
    int ans = 0;
    function<long long(int,int,int)> query = [&](int ty, int l, int r)->long long{
        long long hh = 0;
        if (ty==2){
            hh = dp2[r];
            if (l) hh-=dp2[l-1];
        }
        else if (ty==3){
            hh = dp3[r];
            if (l) hh-=dp3[l-1];
        }
        else {
            hh = dp1[r];
            if (l) hh-=dp1[l-1];
        }
        return hh;
    };
    function<int(int,int,int,int)> calc = [&](int al, int ar, int bl, int br)->int{
        if (max(al,bl)<=min(ar,br)){
            long long ret = query(3,max(al,bl),min(ar,br));
            ret+=query(1,al,max(al,bl)-1);
            ret+=query(1,min(ar,br)+1,ar);
            ret+=query(2,bl,max(al,bl)-1);
            ret+=query(2,min(ar,br)+1,br);
            return ret;
        }
        else {
            return query(1,al,ar)+query(2,bl,br);
        }
    };
    for (int al = 0; al <= X; al++){
        for (int ar = X; ar < N; ar++){
            for (int bl = 0; bl <= Y; bl++){
                if (calc(al,ar,bl,Y)>K) continue;
                int l = Y, r = N-1;
                while (l<r){
                    int mid = l+(r-l+1)/2;
                    if (calc(al,ar,bl,mid)>K){
                        r=mid-1;
                    }
                    else l=mid;
                }
                ans=max(ans,ar-al+1+l-bl+1);
            }
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1006 ms 9700 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 432 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 432 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '18', found: '198'
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 432 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '18', found: '198'
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -