#include<bits/stdc++.h>
#include "closing.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int max_score(int N,int X,int Y,ll K,vector<int>U,vector<int>V,vector<int>W){
if(X>Y) swap(X,Y);
vector<pair<int,int>>adj[N];
for(int i=0;i<N-1;i++){
adj[U[i]].pb({V[i],W[i]});
adj[V[i]].pb({U[i],W[i]});
}
ll D[N];
D[0]=0;
for(int i=1;i<N;i++){
for(auto [j,w]:adj[i]){
if(j==i-1){
D[i]=D[i-1]+w;
}
}
}
ll dist[N];
function <ll(int,int)> calc=[&](int i,int j){
if(i>j) swap(i,j);
if(i==j) return 0ll;
return D[j]-D[i];
};
int ans=0;
for(int l1=0;l1<=X;l1++){
for(int r1=X;r1<N;r1++){
for(int r2=Y;r2<N;r2++){
for(int l2=Y;l2>=0;l2--){
ll total=0;
int cnt=0;
for(int i=0;i<N;i++){
ll cur=0;
if(l1<=i&&i<=r1){
cur=max(cur,calc(i,X));
cnt++;
}
if(l2<=i&&i<=r2){
cur=max(cur,calc(i,Y));
cnt++;
}
total+=cur;
}
if(total<=K){
ans=max(ans,cnt);
}
}
}
}
}
return ans;
}
Compilation message
closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:29:8: warning: unused variable 'dist' [-Wunused-variable]
29 | ll dist[N];
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1064 ms |
22104 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
72 ms |
416 KB |
Output is correct |
7 |
Correct |
53 ms |
348 KB |
Output is correct |
8 |
Correct |
20 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
72 ms |
416 KB |
Output is correct |
7 |
Correct |
53 ms |
348 KB |
Output is correct |
8 |
Correct |
20 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
267 ms |
348 KB |
Output is correct |
13 |
Correct |
177 ms |
348 KB |
Output is correct |
14 |
Correct |
563 ms |
344 KB |
Output is correct |
15 |
Correct |
247 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
15 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
1061 ms |
348 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
72 ms |
416 KB |
Output is correct |
7 |
Correct |
53 ms |
348 KB |
Output is correct |
8 |
Correct |
20 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
267 ms |
348 KB |
Output is correct |
13 |
Correct |
177 ms |
348 KB |
Output is correct |
14 |
Correct |
563 ms |
344 KB |
Output is correct |
15 |
Correct |
247 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
348 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
15 ms |
344 KB |
Output is correct |
19 |
Execution timed out |
1061 ms |
348 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |