Submission #1006899

# Submission time Handle Problem Language Result Execution time Memory
1006899 2024-06-24T09:40:14 Z De3b0o Closing Time (IOI23_closing) C++17
21 / 100
1000 ms 26460 KB
#include "closing.h"
#include<bits/stdc++.h>
#include<random>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)

using namespace std;

ll n , x , y , k;
vector<pll> adj[200009];
ll vis[200009];
ll xx[200009];
ll yy[200009];
ll mx[200009];

int max_score(int N, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    n=N;
    x=X;
    y=Y;
    k=K;
    for(int i = 0 ; n>i ; i++)
    {
        adj[i].clear();
        vis[i]=0;
    }
    for(int i = 0 ; n-1>i ; i++)
    {
        adj[U[i]].pb({V[i],W[i]});
        adj[V[i]].pb({U[i],W[i]});
    }
    ll d = 0;
    for(int i = x ; i>=0 ; i--)
    {
        xx[i]=d;
        if(i)
            d+=W[i-1];
    }
    d=0;
    for(int i = y ; n>i ; i++)
    {
        yy[i]=d;
        if(i<n-1)
            d+=W[i];
    }
    d=0;
    for(int i = x ; n>i ; i++)
    {
        xx[i]=d;
        if(i<n-1)
            d+=W[i];
    }
    d=0;
    for(int i = y ; i>=0 ; i--)
    {
        yy[i]=d;
        if(i)
            d+=W[i-1];
    }
    for(int i = 0 ; n>i ; i++)
        mx[i]=max(xx[i],yy[i]);
    for(int i = 1 ; n>i ; i++)
    {
        xx[i]+=xx[i-1];
        yy[i]+=yy[i-1];
        mx[i]+=mx[i-1];
        if(i==x)
            xx[i]=0;
        if(i==y)
            yy[i]=0;
    }
    ll ans = 0;
    for(int i = x ; n>i ; i++)
    {
        for(int j = y ; j>=0 ; j--)
        {
            for(int i1 = x ; i1>=0 ; i1--)
            {
                ll cost = 0;
                ll ans1 = i-i1+1 + y-j+1;
                if(i>y)
                    ans1+=i-y;
                if(j>=x)
                {
                    if(j<=i)
                    {
                        cost+=mx[i];
                        if(j)
                            cost-=mx[j-1];
                        if(y>i)
                        {
                            cost+=yy[y-1];
                            cost-=yy[i];
                        }
                        if(j>x)
                            cost+=xx[j-1];
                    }
                    else
                    {
                        cost+=xx[i];
                        cost+=yy[y-1];
                        if(j)
                            cost-=yy[j-1];
                    }
                    if(x)
                    {
                        cost+=xx[x-1];
                        if(i1)
                            cost-=xx[i1-1];
                    }
                }
                else
                {
                    cost+=mx[i];
                    if(j)
                        cost-=mx[j-1];
                    if(j)
                    {
                        cost+=xx[j-1];
                        ll idxl = min(i1,j);
                        if(idxl)
                            cost-=xx[idxl-1];
                    }
                    if(y>i)
                    {
                        cost+=yy[y-1];
                        cost-=yy[i];
                    }
                }
                if(cost>k)
                    continue;
                ll l = max(i+1,int(y+1)) , r = n-1;
                ll le = l-1;
                ll re = k-cost;
                while(l<=r)
                {
                    if(yy[mid]-yy[le]>re)
                        r=mid-1;
                    else
                        l=mid+1;
                }
                le++;
                ans1+=l-le;
                ans=max(ans,ans1);
            }
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 11100 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 1038 ms 26460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 11096 KB Output is correct
2 Correct 1 ms 11100 KB Output is correct
3 Correct 2 ms 11100 KB Output is correct
4 Correct 2 ms 11100 KB Output is correct
5 Correct 1 ms 11216 KB Output is correct
6 Correct 2 ms 11100 KB Output is correct
7 Correct 1 ms 11096 KB Output is correct
8 Correct 1 ms 11100 KB Output is correct
9 Correct 1 ms 11100 KB Output is correct
10 Correct 1 ms 11100 KB Output is correct
11 Correct 1 ms 11100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 11096 KB Output is correct
2 Correct 1 ms 11100 KB Output is correct
3 Correct 2 ms 11100 KB Output is correct
4 Correct 2 ms 11100 KB Output is correct
5 Correct 1 ms 11216 KB Output is correct
6 Correct 2 ms 11100 KB Output is correct
7 Correct 1 ms 11096 KB Output is correct
8 Correct 1 ms 11100 KB Output is correct
9 Correct 1 ms 11100 KB Output is correct
10 Correct 1 ms 11100 KB Output is correct
11 Correct 1 ms 11100 KB Output is correct
12 Correct 2 ms 11100 KB Output is correct
13 Correct 1 ms 11100 KB Output is correct
14 Correct 2 ms 11100 KB Output is correct
15 Correct 2 ms 11100 KB Output is correct
16 Correct 2 ms 11100 KB Output is correct
17 Correct 1 ms 11100 KB Output is correct
18 Correct 2 ms 11100 KB Output is correct
19 Correct 121 ms 11232 KB Output is correct
20 Correct 2 ms 11100 KB Output is correct
21 Correct 127 ms 11100 KB Output is correct
22 Correct 3 ms 11100 KB Output is correct
23 Correct 2 ms 11100 KB Output is correct
24 Correct 2 ms 11100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 11096 KB Output is correct
2 Correct 1 ms 11100 KB Output is correct
3 Correct 2 ms 11100 KB Output is correct
4 Correct 2 ms 11100 KB Output is correct
5 Correct 1 ms 11216 KB Output is correct
6 Correct 2 ms 11100 KB Output is correct
7 Correct 1 ms 11096 KB Output is correct
8 Correct 1 ms 11100 KB Output is correct
9 Correct 1 ms 11100 KB Output is correct
10 Correct 1 ms 11100 KB Output is correct
11 Correct 1 ms 11100 KB Output is correct
12 Correct 2 ms 11100 KB Output is correct
13 Correct 1 ms 11100 KB Output is correct
14 Correct 2 ms 11100 KB Output is correct
15 Correct 2 ms 11100 KB Output is correct
16 Correct 2 ms 11100 KB Output is correct
17 Correct 1 ms 11100 KB Output is correct
18 Correct 2 ms 11100 KB Output is correct
19 Correct 121 ms 11232 KB Output is correct
20 Correct 2 ms 11100 KB Output is correct
21 Correct 127 ms 11100 KB Output is correct
22 Correct 3 ms 11100 KB Output is correct
23 Correct 2 ms 11100 KB Output is correct
24 Correct 2 ms 11100 KB Output is correct
25 Correct 8 ms 11100 KB Output is correct
26 Execution timed out 1089 ms 11356 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 11100 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 2 ms 11100 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 2 ms 11100 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 2 ms 11100 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 2 ms 11100 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -