#include <algorithm>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <unordered_set>
#define F first
#define S second
#define PB push_back
using namespace std;
const long long MOD=1e9+7, INF=1e18;
const int INFI=1e9, N_MAX=200000;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<pair<int, ii>> viii;
typedef vector<vii> vvii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
int max_score(int n, int x, int y, ll k, vi u, vi v, vi w)
//int main()
{
/*
int n, x, y;
ll k;
cin>>n>>x>>y>>k;
vi u(n+1), v(n+1), w(n+1);
for(int i=0;i<n-1;i++) cin>>u[i];
for(int i=0;i<n-1;i++) cin>>v[i];
for(int i=0;i<n-1;i++) cin>>w[i];
*/
vvii al(n+1, vii());
vll dist(n+1, INF), clos(n+1);
for(int i=0;i<n-1;i++){
al[u[i]].PB({v[i], w[i]});
al[v[i]].PB({u[i], w[i]});
}
ll sum=0, tot=0, ans=0;
priority_queue<pair<ll, int>> pq;
dist[x]=dist[y]=clos[x]=clos[y]=0;
pq.push({0, x});
pq.push({0, y});
while(!pq.empty()){
int node=pq.top().S;
ll dis=-pq.top().F;
pq.pop();
if(dis!=dist[node]) continue;
sum+=clos[node];
tot++;
if(sum<=k)
ans=tot;
for(auto aux:al[node])
if(dist[aux.F]>dis+aux.S){
pq.push({-dis-aux.S, aux.F});
dist[aux.F]=dis+aux.S;
clos[aux.F]=clos[node]+aux.S;
}
}
//cout<<ans<<endl;
return (int)ans;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
20308 KB |
Output is correct |
2 |
Correct |
81 ms |
19944 KB |
Output is correct |
3 |
Correct |
70 ms |
2720 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '30', found: '17' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |