Submission #960378

# Submission time Handle Problem Language Result Execution time Memory
960378 2024-04-10T11:01:43 Z Prieved1 Closing Time (IOI23_closing) C++17
8 / 100
95 ms 34088 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
vector<pair<int,int>> g[MAXN];
long long distX[MAXN], distY[MAXN];
void dfsx(int at, int p) {
  for(auto [to,w]:g[at]) {
    if(to==p)continue;
    distX[to]=distX[at]+w;
    dfsx(to, at);
  }
}
void dfsy(int at, int p) {
  for(auto [to,w]:g[at]) {
    if(to==p)continue;
    distY[to]=distY[at]+w;
    dfsy(to, at);
  }
}
int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
  for(int i = 0;i<N-1;i++) {
    g[U[i]].push_back({V[i], W[i]});
    g[V[i]].push_back({U[i], W[i]});
  }
  dfsx(X, -1);
  dfsy(Y, -1);
  int ans=0;
  // case 1
  {
    int cnt=0;
    priority_queue<long long> pq;
    for(int i = 0;i<N;i++) {
      pq.push(-distX[i]);
      pq.push(-distY[i]);
    }
    long long sum=0;
    while(sum<=K) {
      sum-=pq.top();
      cnt++;
      pq.pop();
      if(sum<=K)ans=max(ans,cnt);
    }
  }
  for(int i = 0;i<=N;i++) {
    distX[i]=distY[i]=0;
    g[i].clear();
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5980 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 88 ms 31168 KB Output is correct
2 Correct 95 ms 34088 KB Output is correct
3 Correct 52 ms 10936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5976 KB Output is correct
2 Incorrect 2 ms 5980 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5976 KB Output is correct
2 Incorrect 2 ms 5980 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5976 KB Output is correct
2 Incorrect 2 ms 5980 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5980 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 5980 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 5980 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 5980 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 5980 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -