結果

問題 No.1231 Make a Multiple of Ten
ユーザー tomatoma
提出日時 2020-09-18 22:24:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 936 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 202,740 KB
実行使用メモリ 4,592 KB
最終ジャッジ日時 2023-09-05 18:22:40
合計ジャッジ時間 3,462 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 39 ms
4,380 KB
testcase_05 AC 34 ms
4,376 KB
testcase_06 AC 14 ms
4,376 KB
testcase_07 AC 40 ms
4,380 KB
testcase_08 AC 14 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 35 ms
4,380 KB
testcase_11 AC 44 ms
4,380 KB
testcase_12 AC 78 ms
4,544 KB
testcase_13 AC 83 ms
4,592 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 82 ms
4,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"

using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];

    vector<int> remains(10, INF);
    remains[0] = 0;
    for (auto a : A) {
        rep(bef, 10) {
            auto next = (bef + a) % 10;
            remains[next] = min(remains[next], remains[bef] + 1);
        }
    }

    ll tgt = accumulate(A.begin(), A.end(), 0ll) % 10;
    ll res = N - remains[tgt];
    cout << res << endl;
    return 0;
}
0