Submission #1074773

#TimeUsernameProblemLanguageResultExecution timeMemory
1074773dostsBali Sculptures (APIO15_sculpture)C++17
21 / 100
3 ms1940 KiB
//Dost SEFEROĞLU #include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define all(cont) cont.begin(),cont.end() #define vi vector<int> const int MOD = 1e9+7,inf = 2e12; const int N = 5001; void solve() { int n; cin >> n; int l,r; cin >> l >> r; vi a(n+1),p(n+1,0); for (int i=1;i<=n;i++) cin >> a[i]; for (int i=1;i<=n;i++) p[i] = p[i-1]+a[i]; int dp[n+1][20*n+1]; for (int i=0;i<=n;i++) { for (int j=0;j<=20*n;j++) { dp[i][j] = inf; } } dp[0][0] = 0; for (int i=0;i<=n;i++) { for (int s=0;s<=20*n;s++) { if (dp[i][s]>r) continue; for (int k=i+1;k<=n;k++) { int sm = p[k]-p[i]; dp[k][s|sm] = min(dp[k][s|sm],dp[i][s]+1); } } } int ans = inf; for (int i=20*n;i>=0;i--) { for (int j=l;j<=r;j++) { if (dp[n][i]<=r) ans = min(ans,i); } } cout << ans << endl; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #ifdef Dodi freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t = 1; //cin >> t; while (t --> 0) solve(); }
#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...