結果

問題 No.1231 Make a Multiple of Ten
ユーザー kuhakukuhaku
提出日時 2020-09-18 21:32:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 2,180 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 199,836 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 18:10:11
合計ジャッジ時間 3,500 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 42 ms
4,376 KB
testcase_05 AC 37 ms
4,376 KB
testcase_06 AC 15 ms
4,376 KB
testcase_07 AC 43 ms
4,380 KB
testcase_08 AC 16 ms
4,380 KB
testcase_09 AC 10 ms
4,376 KB
testcase_10 AC 38 ms
4,376 KB
testcase_11 AC 46 ms
4,376 KB
testcase_12 AC 84 ms
4,376 KB
testcase_13 AC 88 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 88 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n;
    cin >> n;
    Vec dp(10);
    rep(i, n){
        ll a;
        cin >> a;
        Vec tmp(10);
        rep(i, 10) if (dp[i]) chmax(tmp[(i + a % 10) % 10], dp[i] + 1);
        rep(i, 10) chmax(dp[i], tmp[i]);
        chmax(dp[a % 10], 1);
    }
    co(dp[0]);

    return 0;
}
0