Submission #839817

# Submission time Handle Problem Language Result Execution time Memory
839817 2023-08-30T17:16:58 Z Black_Ghost Closing Time (IOI23_closing) C++17
0 / 100
929 ms 2097152 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mk make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
ll cost[2][3100];
vector<pair<ll,ll> > v[3400];
void go(int cr,ll ds,int pr,int f){
    cost[f][cr]=ds;
    for(auto u:v[cr]){
        if(u.ff==pr)continue;
        go(u.ff,ds+u.ss,cr,f);
    }
}
ll dp[3010][6010];
int n;
ll solve(int cr,int rem){
    if(rem==0)return 0;
    if(cr>=n){
        return 2e18;
    }
    ll &ret=dp[cr][rem];
    if(ret!=-1)return ret;
    ret=3e18;
    ret=min(ret,solve(cr+1,rem));
    ret=min(ret,solve(cr+1,rem-1)+min(cost[0][cr],cost[1][cr]));
    ret=min(ret,solve(cr+1,rem-2)+max(cost[0][cr],cost[1][cr]));
    return ret;
}
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;
    for(int i=0;i<N-1;i++){
        v[U[i]].pb({V[i],W[i]});
        v[V[i]].pb({U[i],W[i]});
    }
    go(X,0,-1,0);
    go(Y,0,-1,1);
    memset(dp,-1,sizeof dp);
    int maxS=0;
    for(int i=0;i<=n*2;i++){
        if(solve(0,i)<=K){
            maxS=i;
        }
    }
    return maxS;
}
# Verdict Execution time Memory Grader output
1 Runtime error 929 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 49 ms 10028 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 141900 KB Output is correct
2 Correct 45 ms 141908 KB Output is correct
3 Correct 46 ms 141908 KB Output is correct
4 Correct 46 ms 141900 KB Output is correct
5 Incorrect 48 ms 142028 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 141900 KB Output is correct
2 Correct 45 ms 141908 KB Output is correct
3 Correct 46 ms 141908 KB Output is correct
4 Correct 46 ms 141900 KB Output is correct
5 Incorrect 48 ms 142028 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 141900 KB Output is correct
2 Correct 45 ms 141908 KB Output is correct
3 Correct 46 ms 141908 KB Output is correct
4 Correct 46 ms 141900 KB Output is correct
5 Incorrect 48 ms 142028 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 929 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 929 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 929 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 929 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 929 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -