Submission #1077943

# Submission time Handle Problem Language Result Execution time Memory
1077943 2024-08-27T10:51:20 Z Dan4Life Closing Time (IOI23_closing) C++17
0 / 100
141 ms 33648 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
 
using ll = long long;
using ar = array<int,2>;
 
const int mxN = (int)3e5+10;
ll n, dis[2][mxN];
vector<pair<int,int>> adj[mxN];
 
void dfs(int s, int p, int t){
	for(auto [u,w] : adj[s]){
		if(u==p) continue; 
		dis[t][u] = dis[t][s]+w; dfs(u,s,t);
	}
}
 
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W){
	n = N; int ans = 0;
	for(int i = 0; i < n; i++){
		adj[i].clear();
		dis[0][i]=dis[1][i]=0;
	}
	for(int i = 0; i < n-1; i++){
		auto [a,b,c] = tie(U[i],V[i],W[i]);
		adj[a].pb({b,c}), adj[b].pb({a,c});
	}
	dfs(X,-1,0); dfs(Y,-1,1);
	priority_queue<ar,vector<ar>,greater<ar>> pq;
	while(sz(pq)) pq.pop();
	for(int i = 0; i < n; i++){
		int mn = min(dis[0][i],dis[1][i]);
		int mx = max(dis[0][i],dis[1][i]);
		pq.push({mn,mx});
	}
	while(sz(pq)){
		auto [sum,mx] = pq.top(); pq.pop();
		if(K<sum) break;
		K-=sum; ans++;
		if(mx!=-1) pq.push({mx-sum,-1});
	}
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7260 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 33648 KB 1st lines differ - on the 1st token, expected: '451', found: '400000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7260 KB Output is correct
2 Correct 4 ms 7260 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Incorrect 3 ms 7260 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 3 ms 7260 KB Output is correct
2 Correct 4 ms 7260 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Incorrect 3 ms 7260 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 3 ms 7260 KB Output is correct
2 Correct 4 ms 7260 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 2 ms 7260 KB Output is correct
5 Incorrect 3 ms 7260 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 Incorrect 3 ms 7260 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7260 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7260 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7260 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 7260 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -