Contest Duration: - (local time) (100 minutes) Back to Home

Submission #9783902

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     @hamayanhamayan0
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

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

rep(i, 0, N + 1) rep(h, 0, H + 1) dp[i][h] = inf;
dp[0][H] = 0;

rep(i, 0, N) rrep(h, H, 0) {
chmin(dp[i + 1][h], dp[i][h]);
chmin(dp[i][max(0, h - A[i])], dp[i][h] + B[i]);
}

cout << dp[N][0] << endl;
}

```

#### Submission Info

Submission Time 2020-01-27 19:51:58+0900 E - Crested Ibis vs Monster hamayanhamayan C++14 (GCC 5.4.1) 500 1736 Byte AC 31 ms 39936 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
 AC × 3
 AC × 24
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All corner_01, corner_02, hand_01, hand_02, hand_03, max_01, max_02, max_03, max_04, max_05, max_06, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
corner_01 AC 14 ms 32000 KB
corner_02 AC 12 ms 37760 KB
hand_01 AC 1 ms 384 KB
hand_02 AC 1 ms 384 KB
hand_03 AC 1 ms 384 KB
max_01 AC 29 ms 39168 KB
max_02 AC 22 ms 28928 KB
max_03 AC 30 ms 39168 KB
max_04 AC 31 ms 39808 KB
max_05 AC 31 ms 39808 KB
max_06 AC 31 ms 39808 KB
random_01 AC 7 ms 21120 KB
random_02 AC 15 ms 32000 KB
random_03 AC 7 ms 11648 KB
random_04 AC 11 ms 21888 KB
random_05 AC 2 ms 3072 KB
random_06 AC 31 ms 39808 KB
random_07 AC 30 ms 39936 KB
random_08 AC 30 ms 39808 KB
random_09 AC 30 ms 39808 KB
random_10 AC 30 ms 39808 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 2 ms 768 KB