Submission #2312685


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/






int N, M, L, X, A[10101], dp[10101][1010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> L >> X;
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N + 1) rep(j, 0, M) dp[i][j] = inf;
    dp[0][0] = 1;

    rep(i, 0, N) rep(j, 0, M) {
        if (M <= j + A[i]) {
            int x = A[i];
            int d = 0;
            
            d++;
            x -= M - j;

            d += x / M;
            x %= M;

            chmin(dp[i + 1][x], dp[i][j] + d);
        }
        else chmin(dp[i + 1][j + A[i]], dp[i][j]);
        chmin(dp[i + 1][j], dp[i][j]);
    }

    if (dp[N][L] <= X) printf("Yes\n");
    else printf("No\n");
}

Submission Info

Submission Time
Task D - Many Go Round
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1999 Byte
Status
Exec Time 55 ms
Memory 39808 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 100 / 100 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 1 ms 256 KB
02.txt 1 ms 256 KB
03.txt 1 ms 256 KB
04.txt 1 ms 256 KB
05.txt 1 ms 256 KB
06.txt 1 ms 256 KB
07.txt 1 ms 256 KB
08.txt 1 ms 256 KB
09.txt 55 ms 39808 KB
10.txt 55 ms 39808 KB
11.txt 1 ms 384 KB
12.txt 1 ms 256 KB
13.txt 1 ms 256 KB
14.txt 1 ms 256 KB
15.txt 1 ms 256 KB
16.txt 1 ms 256 KB
17.txt 55 ms 39808 KB
18.txt 55 ms 39808 KB
19.txt 29 ms 39808 KB
20.txt 29 ms 39808 KB
21.txt 1 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB