# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
579715 | wdjpng | Uplifting Excursion (BOI22_vault) | C++17 | 5027 ms | 8148 KiB |
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 <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >=0; i--)
#pragma GCC optimize("O3")
#pragma optimize("sse,sse2,sse3,sse4,avx,avx2")
using namespace std;
signed main()
{
int m,l;
cin>>m>>l;
int maxl=(m)*(m+1)/2*100; //TODO change to 100
if(l>maxl) {cout<<"impossible\n"; exit(0);}
vector<int>dp(2*maxl, -1);
dp[maxl]=0;
for(int cl = -m; cl <= m; cl++)
{
int a;
cin>>a;
rep(whatever,a)
{
if(cl>0)
{
per(i,2*maxl+1)
{
if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
dp[i]=max(dp[i], dp[i-cl]+1);
}
} else
rep(i,2*maxl+1)
{
if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
dp[i]=max(dp[i], dp[i-cl]+1);
}
}
}
if(l+maxl<dp.size()&&dp[l+maxl]>0) cout<<dp[l+maxl]<<'\n';
else cout<<"impossible\n";
}
Compilation message (stderr)
# | 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... |