답안 #844881

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844881 2023-09-06T06:45:15 Z vjudge1 Holding (COCI20_holding) C++17
110 / 110
588 ms 8648 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;
//4397524
 
void solve() {
    int n,l,r,K;
    cin >> n >> l >> r >> K;
    int rng = (r-l+1);
    vvi dp(rng+1,vi(K+1,inf)),dp2(rng+1,vi(K+1,inf));
    dp2[0][0] = 0;
    vi a(n+1);
    F(i,n) cin >> a[i];
    F(i,n) {
        FF(j,0,rng) {
            FF(k,0,K) {
                dp[j][k] = min(dp[j][k],dp2[j][k]);
                if (k >= abs(l+j-1-i) && j) {
                    dp[j][k] = min(dp[j][k],dp2[j-1][k-abs(l+j-1-i)]+a[i]);
                }
            }
        }
        dp2 = dp;
    }
    int mini = inf;
    FF(k,0,K) mini = min(mini,dp[rng][k]);
    cout << 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"
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 548 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 11 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 548 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 11 ms 1624 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 154 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 548 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 11 ms 1624 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 154 ms 4696 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 154 ms 4736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 548 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 11 ms 1624 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 154 ms 4696 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 154 ms 4736 KB Output is correct
20 Correct 6 ms 344 KB Output is correct
21 Correct 4 ms 600 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 13 ms 600 KB Output is correct
24 Correct 22 ms 600 KB Output is correct
25 Correct 588 ms 8648 KB Output is correct