結果

問題 No.385 カップ麺生活
ユーザー CleyLCleyL
提出日時 2022-08-20 22:40:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,043 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 80,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 20:12:48
合計ジャッジ時間 3,101 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 5 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 38 ms
6,944 KB
testcase_05 AC 10 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 5 ms
6,944 KB
testcase_08 AC 19 ms
6,940 KB
testcase_09 AC 53 ms
6,940 KB
testcase_10 WA -
testcase_11 AC 25 ms
6,940 KB
testcase_12 AC 73 ms
6,940 KB
testcase_13 AC 14 ms
6,944 KB
testcase_14 AC 25 ms
6,944 KB
testcase_15 AC 4 ms
6,944 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 15 ms
6,944 KB
testcase_18 AC 7 ms
6,940 KB
testcase_19 AC 37 ms
6,944 KB
testcase_20 AC 13 ms
6,940 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 4 ms
6,944 KB
testcase_24 WA -
testcase_25 AC 5 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 4 ms
6,940 KB
testcase_30 AC 3 ms
6,944 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 3 ms
6,944 KB
testcase_33 AC 18 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
struct SieveEratos{
  vector<bool> t;
  vector<int> primes;
  SieveEratos(int n):t(n+1,true){
    t[0] = t[1] = false;
    for(int i = 2; n >= i; i++){
      if(t[i]){
        primes.emplace_back(i);
        for(int j = i+i; n >= j; j+=i){
          t[j] = false;
        }
      }
    }
  }
  bool operator[](int x){return t[x];}
};

int main(){
    int m,n;cin>>m>>n;
    vector<long long> A(10001,10001);
    A[0] = 0;
    int mn = 1000;
    for(int i = 0; n > i; i++){
        int c;cin>>c;
        mn = min(c,mn);
        for(int j = 0; 10000 >= j; j++){
            if(A[j] == 10001)continue;
            for(int k = j+c; 10000 >= k; k+=c){
                if(A[k] == 10001)A[k] = A[j]+((k-j)/c);
                else A[k] = max(A[k],A[j]+((k-j)/c));
            }
        }
    }
    SieveEratos P(10001);
    long long ans = 0;
    for(int i = 1; m > i; i++){
        if(P[i] && A[m-i] != 10001){
            ans += A[m-i];
        }
    }
    cout << ans+(m-1)/mn << endl;
}
0