結果

問題 No.1231 Make a Multiple of Ten
コンテスト
ユーザー mencotton
提出日時 2020-11-02 15:20:56
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 504 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 588 ms
コンパイル使用メモリ 89,696 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-03 07:46:29
合計ジャッジ時間 2,121 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge2_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/vector:67,
                 from main.cpp:2:
In function '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = int*; _ForwardIterator = int*]',
    inlined from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _Sentinel, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = int*; _Sentinel = int*; _ForwardIterator = int*; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_uninitialized.h:637:37,
    inlined from 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/vector.tcc:257:35,
    inlined from 'int main()' at main.cpp:24:14:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_uninitialized.h:273:31: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' writing between 1 and 40 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
  273 |               __builtin_memcpy(std::__niter_base(__result),
      |               ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  274 |                                std::__niter_base(__first),
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  275 |                                __n * sizeof(_ValT));
      |                                ~~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/allocator.h:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
    

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;

    int sum = 0;
    vector<int> dp(10, n);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += a, sum %= 10;

        vector<int> after(10, n);
        for (int j = 0; j < 10; j++) {
            after[(j + a) % 10] = min(dp[(j + a) % 10], dp[j] + 1);
        }
        dp = after;
    }

    cout << n - dp[sum] << endl;
    return 0;
}
0