Submission #1069823

# Submission time Handle Problem Language Result Execution time Memory
1069823 2024-08-22T09:13:25 Z Sir_Ahmed_Imran Closing Time (IOI23_closing) C++17
21 / 100
1000 ms 13532 KB
                            ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 3000
ll c[N];
int vis[N][2];
vector<pll> a[N];
int solve(int n,int x,int y,ll k){
    priority_queue<pair<ll,pii>,vector<pair<ll,pii>>,greater<pair<ll,pii>>> Q;
    for(int i=0;i<n;i++)
        for(int j=0;j<2;j++)
            vis[i][j]=0;
    Q.push({0,{x,0}});
    Q.push({0,{y,1}});
    ll p,q,r;
    int ans=0;
    while(!Q.empty() && k>=Q.top().ff){
        p=Q.top().ss.ff;
        r=Q.top().ss.ss;
        q=Q.top().ff;
        Q.pop();
        if(vis[p][r]) continue;
        vis[p][r]=1;
        ans++;
        k-=q;
        for(auto& i:a[p]){
            if(vis[i.ff][r])
                continue;
            Q.push({q+i.ss,{i.ff,r}});
        }
    }
    return ans;
}
int max_score(int n,int x,int y,ll k,vector<int> u,vector<int> v,vector<int> w){
    int m,t,ans;
    ll o,p,q,r,s;
    ans=m=t=0;
    if(x>y) swap(x,y);
    for(int i=0;i<n-1;i++){
        a[v[i]].append({u[i],w[i]});
        a[u[i]].append({v[i],w[i]});
        if(abs(v[i]-u[i])>1) t=1;
    }
    if(t) return solve(n,x,y,k);
    priority_queue<pair<ll,pll>,vector<pair<ll,pll>>,greater<pair<ll,pll>>> Q;
    for(int i=x;i<n;i++){
        r=k;
        for(int j=o=0;j<=x;j++)
            c[j]=0;
        for(int j=i+1;j<n;j++)
            c[j]=0;
        for(int j=x;j<i;j++){
            o+=w[j];
            c[j+1]=o;
            r-=o;
        }
        o=0;
        if(r<0) break;
        for(int j=y;j>=0;j--){
            if(o-c[j]>r) break;
            r-=max(0LL,o-c[j]);
            c[j]=max(c[j],o);
            m=i-x+y-j;
            s=r;
            Q.push({0,{0,x}});
            Q.push({0,{0,y}});
            while(!Q.empty() && Q.top().ff<=s){
                p=Q.top().ff;
                q=Q.top().ss.ff;
                t=Q.top().ss.ss;
                Q.pop();
                s-=p;
                m++;
                if(t<=x && t){
                    q+=w[t-1];
                    p=max(0LL,q-c[t-1]);
                    Q.push({p,{q,t-1}});
                }
                if(t>=y && t<n-1){
                    q+=w[t];
                    p=max(0LL,q-c[t+1]);
                    Q.push({p,{q,t+1}});
                }
            }
            while(!Q.empty()) Q.pop();
            ans=max(ans,m);
            if(j) o+=w[j-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 Runtime error 79 ms 13532 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 324 ms 524 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 644 ms 524 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 604 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 324 ms 524 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 644 ms 524 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 37 ms 652 KB Output is correct
26 Execution timed out 1047 ms 600 KB Time limit exceeded
27 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 -