Submission #869720

#TimeUsernameProblemLanguageResultExecution timeMemory
869720Ahmed_SolymanUplifting Excursion (BOI22_vault)C++14
0 / 100
1 ms604 KiB
/* In the name of Allah made by: Ahmed_Solyman */ #include <bits/stdc++.h> #include <ext/rope> using namespace std; using namespace __gnu_cxx; #pragma GCC optimize("-Ofast") #pragma GCC optimize("-O1") //-------------------------------------------------------------// typedef long long ll; typedef unsigned long long ull; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define PI acos(-1) #define lb lower_bound #define ub upper_bound #define endl '\n' #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define sum_to(n) (n*(n+1))/2 #define pb push_back #define pf push_front #define fil(arr,x) memset(arr,x,sizeof(arr)) const ll mod=1e9+7; int dx[8]={0,1,0,-1,1,1,-1,-1}; int dy[8]={1,0,-1,0,1,-1,-1,1}; //-------------------------------------------------------------// ll lcm(ll a,ll b) { return (max(a,b)/__gcd(a,b))*min(a,b); } void person_bool(bool x) { cout<<(x?"YES":"NO")<<endl; } int dp[10][1000][10],arr[10],n,m; int solve(int i,int sum,int cnt){ if(i==n*2+1){ return ((sum-cnt*n)!=m)*-1e9; } int &ret=dp[i][sum][cnt]; if(~ret)return ret; ret=-1e9; for(int j=0;j<=arr[i];j++){ ret=max(ret,solve(i+1,sum+j*i,cnt+j)+j); } return ret; } int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); #ifndef ONLINE_JUDGE //freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); #endif fast cin>>n>>m; for(int i=0;i<n*2+1;i++)cin>>arr[i]; fil(dp, -1); if(solve(0,0,0)<0)cout<<"impossible"<<endl; else cout<<dp[0][0][0]<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...