#include "closing.h"
#include<bits/stdc++.h>
#include<random>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)
using namespace std;
ll n , x , y , k;
vector<pll> adj[200009];
ll vis[200009];
int max_score(int N, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
n=N;
x=X;
y=Y;
k=K;
for(int i = 0 ; n>i ; i++)
{
adj[i].clear();
vis[i]=0;
}
for(int i = 0 ; n-1>i ; i++)
{
adj[U[i]].pb({V[i],W[i]});
adj[V[i]].pb({U[i],W[i]});
}
vector<pll> xx , yy;
ll d = 0;
for(int i = x ; i>=0 ; i--)
{
xx.pb({d,x-i+1});
if(i)
d+=W[i-1];
}
d=0;
for(int i = y ; n>i ; i++)
{
yy.pb({d,i-y+1});
if(i<n-1)
d+=W[i];
}
vector<pll> v;
for(auto it1 : xx)
{
for(auto it2 : yy)
{
v.pb({it1.F+it2.F,it1.S+it2.S});
}
}
sort(v.begin(),v.end());
ll mx = 0;
vector<ll> c;
for(auto it : v)
{
mx=max(mx,it.S);
c.pb(mx);
}
ll ans = 0;
for(int i = x ; n>i ; i++)
{
for(int j = y ; j>=0 ; j--)
{
ll ans1 = i-x + y-j;
ll vs[n];
memset(vs,-1,sizeof(vs));
d = 0;
for(int h = x ; i>=h ; h++)
{
vs[h]=max(vs[h],d);
if(h<n-1)
d+=W[h];
}
d=0;
for(int h = y ; h>=j ; h--)
{
vs[h]=max(vs[h],d);
if(h)
d+=W[h-1];
}
ll cost = 0;
for(int i = 0 ; n>i ; i++)
{
if(vs[i]!=-1)
cost+=vs[i];
}
if(cost>k)
continue;
ll re = k-cost;
ll l = 0 , r = v.size()-1;
while(l<=r)
{
if(v[mid].F>re)
r=mid-1;
else
l=mid+1;
}
if(l)
ans1+=c[l-1];
ans=max(ans,ans1);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1044 ms |
1075304 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '33' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '33' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '33' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '33' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '33' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '33' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '33' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
1 ms |
6492 KB |
1st lines differ - on the 1st token, expected: '30', found: '33' |
4 |
Halted |
0 ms |
0 KB |
- |