結果

問題 No.288 貯金箱の仕事
ユーザー char134217728char134217728
提出日時 2017-07-30 07:00:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 861 bytes
コンパイル時間 1,264 ms
コンパイル使用メモリ 157,932 KB
実行使用メモリ 5,504 KB
最終ジャッジ日時 2024-04-19 05:12:05
合計ジャッジ時間 3,945 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,376 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 27 ms
5,504 KB
testcase_31 AC 25 ms
5,376 KB
testcase_32 AC 46 ms
5,376 KB
testcase_33 AC 51 ms
5,376 KB
testcase_34 AC 69 ms
5,376 KB
testcase_35 AC 65 ms
5,376 KB
testcase_36 WA -
testcase_37 AC 27 ms
5,376 KB
testcase_38 WA -
testcase_39 AC 29 ms
5,376 KB
testcase_40 AC 36 ms
5,376 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 51 ms
5,376 KB
testcase_44 WA -
testcase_45 AC 48 ms
5,376 KB
testcase_46 AC 72 ms
5,376 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 24 ms
5,376 KB
testcase_50 WA -
testcase_51 AC 24 ms
5,376 KB
testcase_52 AC 42 ms
5,376 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:17:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   17 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e8;
const int mod = 1e9+7;

ll dp[250001];
ll n, m, a[500], k[500], q;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n)cin >> a[i];
  FOR(i, 0, n)cin >> k[i];
  q = a[n - 1];
  q *= q;
  FOR(i, 1, q)dp[i] = inf;
  m *= -1;
  FOR(i, 0, n)m += a[i] * k[i];
  if(m < 0){
    cout << -1 << endl;
    return 0;
  }
  FORR(i, n-1, 0){
    ll d = a[i];
    FOR(j, d, q){
      dp[j] = min(dp[j], dp[j - d] + 1);
    }
  }
  ll t = 0;
  if(m >= q){
    t = (m - q)/a[n-1] + 1;
    m -= t * a[n-1];
  }
  t += dp[m];
  if(t >= inf)t = -1;
  cout << t << endl;
}
0