#include "closing.h"
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
int max_score(int N, int X, int Y, ll K,vi U, vi V, vi W)
{
vector<vpi> paths(2e5+5);
FOR(i,0,N-1){
paths[U[i]].pb({V[i],W[i]});
paths[V[i]].pb({U[i],W[i]});
}
priority_queue<pair<ll,pi>> arr;
vl closing_times(N,0);
int ans = 0;
arr.push({-0,{X,-1}});
arr.push({-0,{Y,-1}});
while(!arr.empty()){
int node = arr.top().S.F;
int prev = arr.top().S.S;
ll dist = -arr.top().F;
ll diff = max(dist - closing_times[node],0LL);
arr.pop();
// cout << K << " " << dist << " " << diff << " " << node << endl;
if(diff > K)continue;
K-=diff;
ans += 1;
closing_times[node] += diff;
for(pi edges:paths[node]){
if(edges.F == prev)continue;
arr.push({-(dist+edges.S),{edges.F,node}});
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
22236 KB |
Output is correct |
2 |
Correct |
60 ms |
21840 KB |
Output is correct |
3 |
Correct |
123 ms |
10044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
5044 KB |
Output is correct |
5 |
Correct |
2 ms |
4956 KB |
Output is correct |
6 |
Correct |
2 ms |
4952 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
5044 KB |
Output is correct |
11 |
Correct |
2 ms |
5036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
5044 KB |
Output is correct |
5 |
Correct |
2 ms |
4956 KB |
Output is correct |
6 |
Correct |
2 ms |
4952 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
5044 KB |
Output is correct |
11 |
Correct |
2 ms |
5036 KB |
Output is correct |
12 |
Correct |
2 ms |
5040 KB |
Output is correct |
13 |
Incorrect |
2 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Correct |
1 ms |
5044 KB |
Output is correct |
5 |
Correct |
2 ms |
4956 KB |
Output is correct |
6 |
Correct |
2 ms |
4952 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
5044 KB |
Output is correct |
11 |
Correct |
2 ms |
5036 KB |
Output is correct |
12 |
Correct |
2 ms |
5040 KB |
Output is correct |
13 |
Incorrect |
2 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5128 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
5044 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4952 KB |
Output is correct |
8 |
Correct |
2 ms |
5208 KB |
Output is correct |
9 |
Incorrect |
1 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '9', found: '8' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5128 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
5044 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
2 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
4956 KB |
Output is correct |
11 |
Correct |
2 ms |
5044 KB |
Output is correct |
12 |
Correct |
2 ms |
5036 KB |
Output is correct |
13 |
Correct |
2 ms |
5040 KB |
Output is correct |
14 |
Incorrect |
2 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5128 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
5044 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
2 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
4956 KB |
Output is correct |
11 |
Correct |
2 ms |
5044 KB |
Output is correct |
12 |
Correct |
2 ms |
5036 KB |
Output is correct |
13 |
Correct |
2 ms |
5040 KB |
Output is correct |
14 |
Incorrect |
2 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5128 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
5044 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
2 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
4956 KB |
Output is correct |
11 |
Correct |
2 ms |
5044 KB |
Output is correct |
12 |
Correct |
2 ms |
5036 KB |
Output is correct |
13 |
Correct |
2 ms |
5040 KB |
Output is correct |
14 |
Incorrect |
2 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5128 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
5044 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
2 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
2 ms |
4956 KB |
Output is correct |
11 |
Correct |
2 ms |
5044 KB |
Output is correct |
12 |
Correct |
2 ms |
5036 KB |
Output is correct |
13 |
Correct |
2 ms |
5040 KB |
Output is correct |
14 |
Incorrect |
2 ms |
4956 KB |
1st lines differ - on the 1st token, expected: '18', found: '17' |
15 |
Halted |
0 ms |
0 KB |
- |