#include "closing.h"
#include <bits/stdc++.h>
#define ll long long
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repr(a,b,c) for(int a=b-1; a>c-1; a--)
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
using namespace std;
const int lim=2e5+5;
vector<pll> adj[lim];
ll ant[lim], nxt[lim];
bool vis[lim];
ll K2, a[lim];
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W){
if(K>3000) return 0;
rep(i,0,N) adj[i].clear(), a[i]=0;
rep(i,0,N-1){
if(U[i]<V[i]) nxt[U[i]]=W[i], ant[V[i]]=W[i];
else ant[U[i]]=W[i], nxt[V[i]]=W[i];
}
int ans=0, ANS=0;
K2=K;
ll sum=0, dis[N]{}, disx[N]{}, disy[N]{};
priority_queue<pll, vector<pll>, greater<pll>> pq;
sum=0;
rep(k,X,N) disx[k]=sum, sum+=nxt[k];
sum=0;
repr(k,X+1,0) disx[k]=sum, sum+=ant[k];
sum=0;
rep(k,Y,N) disy[k]=sum, sum+=nxt[k];
sum=0;
repr(k,Y+1,0) disy[k]=sum, sum+=ant[k];
sum=0;
rep(i,0,N+1){
K=K2;
bool vis[N]{};
ans=0;
rep(i,0,N){
pq.push({max(disx[i],disy[i]),i});
}
rep(j,0,N){
if(K>=pq.top().fi){
vis[pq.top().se]=true;
K-=pq.top().fi;
ans+=2;
pq.pop();
}else break;
}
while(pq.size()) pq.pop();
rep(i,0,N){
if(vis[i]) continue;
pq.push({disx[i],i});
pq.push({disy[i],i});
}
while(pq.size()){
if(K>=pq.top().fi){
K-=pq.top().fi;
ans++;
pq.pop();
}else break;
}
while(pq.size()) pq.pop();
ANS=max(ans,ANS);
}
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:28:12: warning: unused variable 'dis' [-Wunused-variable]
28 | ll sum=0, dis[N]{}, disx[N]{}, disy[N]{};
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
10072 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 |
44 ms |
10420 KB |
1st lines differ - on the 1st token, expected: '451', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Incorrect |
1 ms |
5724 KB |
1st lines differ - on the 1st token, expected: '30', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Incorrect |
1 ms |
5724 KB |
1st lines differ - on the 1st token, expected: '30', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9820 KB |
Output is correct |
2 |
Incorrect |
1 ms |
5724 KB |
1st lines differ - on the 1st token, expected: '30', found: '0' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
10072 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 |
10072 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 |
10072 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 |
10072 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 |
10072 KB |
1st lines differ - on the 1st token, expected: '6', found: '5' |
2 |
Halted |
0 ms |
0 KB |
- |