This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "closing.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <utility>
#define F first
#define S second
#define P pair
#define pb push_back
#define all(v) v.begin(),v.end()
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
int max_score(int N, int X, int Y, long long K,
std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
ll closing[N];
memset(closing,0,sizeof(closing));
int ans=0;
for(int i=X;i<N;i++){
for(int j=X;j>=0;j--){
for(int a=Y;a<N;a++){
ll sum=0;
ll k=K;
memset(closing,0,sizeof(closing));
for(int g=X;g<i;g++) {
sum += W[g];
closing[g + 1] =max(closing[g+1],sum);
}
sum=0;
for(int g=Y;g<a;g++){
sum+=W[g];
closing[g + 1] =max(closing[g+1],sum);
}
sum=0;
for(int g=X-1;g>=j;g--) {
sum += W[g];
closing[g] = max(closing[g], sum);
}
for(int g=0;g<N;g++){
k-=closing[g];
}
if(k>=0){
int c=X-j+i-X+a-Y;
sum=0;
for(int g=Y-1;g>=0;g--){
sum+=W[g];
k+=closing[g];
closing[g]=max(closing[g],sum);
k-=closing[g];
if(k>=0)
c++;
else
break;
}
ans=max(ans,c+2);
}
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |