# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
844870 |
2023-09-06T06:24:42 Z |
dosts |
Holding (COCI20_holding) |
C++14 |
|
0 ms |
344 KB |
#include <bits/stdc++.h>
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
using namespace std;
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi>
#define vp vector<pii>
#define sp << " " <<
#define all(x) x.bg()+1,x.end()
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back
const int inf = 1e18;
const int MOD = 998244353;
const int N = 2e5+1;
void solve() {
int n,l,r,K;
cin >> n >> l >> r >> K;
int rng = (r-l+1);
int dp[n+1][rng+1][K+1];
FF(i,0,n) FF(j,0,rng) FF(k,0,K) dp[i][j][k] = inf;
dp[0][0][0] = 0;
vi a(n+1);
F(i,n) cin >> a[i];
for (int i=1;i<=n;i++) {
for (int j=0;j<=rng;j++) {
for (int k=0;k<=K;k++) {
dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k]);
if (k >= (abs((l+j-1)-i)) && j) {
dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-1][k-abs(((l+j-1)-i))]+(a[i]-a[l+j-1]));
}
}
}
}
int sm =0;
FF(i,l,r) sm+=a[i];
int mini = 0;
F(j,rng){
F(k,K) mini = min(mini,dp[n][j][k]);
}
cout << sm+mini << endl;
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef Local
freopen("input.in", "r", stdin);
freopen("input.out", "w", stdout);
#endif
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
Compilation message
holding.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
2 | #pragma optimize "DostSeferoğlu"
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |