# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
870703 | 2023-11-09T00:41:53 Z | amogususus | Holding (COCI20_holding) | C++17 | 21 ms | 25184 KB |
#pragma GCC optimize("O2,unroll-loops,inline") #pragma GCC target("avx2,bmi,bmi2") #include<bits/stdc++.h> #define ll int #define ld long double #define pb push_back #define prec fixed<<setprecision #define endl '\n' #define all(x) x.begin(),x.end() #define pll pair<ll,ll> #define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);} using namespace std; const int maxN=103; const int mod=998244353; ll n,l,r,z,a[maxN],f[102][102][2503],g[102][102][2503]; void Enter(){ cin>>n>>l>>r>>z; z=min(z,n*n/4); ll res=0; for(int i=1;i<=n;i++){ cin>>a[i]; if(l<=i&&i<=r)res+=a[i]; } //f[i][j][k]=so tien giam bot lon nhat khi thay [L,j] bang cac ptu trong [1,i] voi chi phi k, swap(a[i],a[j]) // tuong tu voi g for(int i=1;i<l;i++)for(int j=l;j<=r;j++)for(int k=0;k<=z;k++){ f[i][j][k]=max(f[i][j][k],f[i-1][j][k]); f[i][j][k]=max(f[i][j][k],f[i][j-1][k]); if(k>=j-i)f[i][j][k]=max(f[i][j][k],f[i-1][j-1][k-j+i]+a[j]-a[i]); } for(int i=n;i>r;i--)for(int j=r;j>=l;j--)for(int k=0;k<=z;k++){ g[j][i][k]=max(g[j][i][k],g[j][i+1][k]); g[j][i][k]=max(g[j][i][k],g[j+1][i][k]); if(k>=i-j)g[j][i][k]=max(g[j][i][k],g[j+1][i+1][k+j-i]+a[j]-a[i]); } ll x=max(f[l-1][r][z],g[l][r+1][z]); for(int i=l;i<=r;i++)for(int k=0;k<=z;k++)x=max(x,f[l-1][i][k]+g[i+1][r+1][z-k]); cout<<res-x; } //amogus signed main(){ open("DEBT"); cin.tie(nullptr);ios_base::sync_with_stdio(NULL); //ll t=1;cin>>t;while(t--) Enter(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 604 KB | Output is correct |
8 | Correct | 2 ms | 2652 KB | Output is correct |
9 | Correct | 2 ms | 2908 KB | Output is correct |
10 | Correct | 2 ms | 3164 KB | Output is correct |
11 | Correct | 2 ms | 3304 KB | Output is correct |
12 | Correct | 1 ms | 2136 KB | Output is correct |
13 | Correct | 3 ms | 4444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 604 KB | Output is correct |
8 | Correct | 2 ms | 2652 KB | Output is correct |
9 | Correct | 2 ms | 2908 KB | Output is correct |
10 | Correct | 2 ms | 3164 KB | Output is correct |
11 | Correct | 2 ms | 3304 KB | Output is correct |
12 | Correct | 1 ms | 2136 KB | Output is correct |
13 | Correct | 3 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 1116 KB | Output is correct |
16 | Correct | 1 ms | 1628 KB | Output is correct |
17 | Correct | 1 ms | 1884 KB | Output is correct |
18 | Correct | 2 ms | 2908 KB | Output is correct |
19 | Correct | 2 ms | 4440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 604 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 604 KB | Output is correct |
8 | Correct | 2 ms | 2652 KB | Output is correct |
9 | Correct | 2 ms | 2908 KB | Output is correct |
10 | Correct | 2 ms | 3164 KB | Output is correct |
11 | Correct | 2 ms | 3304 KB | Output is correct |
12 | Correct | 1 ms | 2136 KB | Output is correct |
13 | Correct | 3 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 1116 KB | Output is correct |
16 | Correct | 1 ms | 1628 KB | Output is correct |
17 | Correct | 1 ms | 1884 KB | Output is correct |
18 | Correct | 2 ms | 2908 KB | Output is correct |
19 | Correct | 2 ms | 4440 KB | Output is correct |
20 | Correct | 4 ms | 6488 KB | Output is correct |
21 | Correct | 2 ms | 2908 KB | Output is correct |
22 | Correct | 2 ms | 4444 KB | Output is correct |
23 | Correct | 3 ms | 2832 KB | Output is correct |
24 | Correct | 7 ms | 12124 KB | Output is correct |
25 | Correct | 21 ms | 25184 KB | Output is correct |