Submission #939894

# Submission time Handle Problem Language Result Execution time Memory
939894 2024-03-06T23:04:46 Z AdamGS Closing Time (IOI23_closing) C++17
8 / 100
120 ms 42272 KB
#include "closing.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e5+7;
vector<pair<ll,ll>>V[LIM];
ll odl[LIM][2], czy[LIM], n;
void DFS(int x, int o, int k) {
  for(auto i : V[x]) if(i.st!=o) {
    odl[i.st][k]=odl[x][k]+i.nd;
    DFS(i.st, x, k);
  }
}
int max_score(int _N, int x, int y, ll k, vector<int>_U, vector<int>_V, vector<int>_W) {
  n=_N;
  rep(i, n) {
    V[i].clear();
    odl[i][0]=odl[i][1]=czy[i]=0;
  }
  rep(i, n-1) {
    V[_U[i]].pb({_V[i], _W[i]});
    V[_V[i]].pb({_U[i], _W[i]});
  }
  DFS(x, x, 0);
  DFS(y, y, 1);
  vector<ll>P;
  ll sum1=0;
  int ans1=0;
  rep(i, n) {
    if(odl[i][0]>odl[i][1]) swap(odl[i][0], odl[i][1]);
    odl[i][1]-=odl[i][0];
    P.pb(odl[i][0]);
  }
  sort(all(P));
  for(auto i : P) if(sum1+i<=k) {
    sum1+=i;
    ++ans1;
  }
  return ans1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 7512 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 Correct 109 ms 35912 KB Output is correct
2 Correct 120 ms 42272 KB Output is correct
3 Correct 61 ms 12624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Incorrect 2 ms 7516 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Incorrect 2 ms 7516 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Incorrect 2 ms 7516 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 7512 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 7512 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 7512 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 7512 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 7512 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -