結果

問題 No.1231 Make a Multiple of Ten
ユーザー sapphire__15sapphire__15
提出日時 2020-10-05 01:02:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 1,845 bytes
コンパイル時間 1,186 ms
コンパイル使用メモリ 108,016 KB
実行使用メモリ 18,292 KB
最終ジャッジ日時 2023-09-27 01:17:43
合計ジャッジ時間 2,757 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 47 ms
9,900 KB
testcase_05 AC 41 ms
8,876 KB
testcase_06 AC 18 ms
5,660 KB
testcase_07 AC 49 ms
10,164 KB
testcase_08 AC 20 ms
7,352 KB
testcase_09 AC 11 ms
4,436 KB
testcase_10 AC 44 ms
9,336 KB
testcase_11 AC 52 ms
10,580 KB
testcase_12 AC 95 ms
16,916 KB
testcase_13 AC 99 ms
17,880 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 98 ms
18,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# ifndef ONLINE_JUDGE
template<typename T>
void vdeb(std::vector<T> &bb) {
    for (int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &bb) {
    for (int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}
# endif

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> da(n);
    rip(i,n,0) cin >> da[i];
    vector<vector<int>> dp(n+1, vector<int>(10, -n*2));
    dp[0][0] = 0;
    rip(i,n,0) {
        int now = da[i]%10;
        rip(j,10,0){
            chmax(dp[i+1][j], dp[i][j]);
            chmax(dp[i+1][j], dp[i][(j+now)%10]+1);
        }
    }
    // vdeb(dp);
    cout << dp[n][0] << endl;
}
0