Submission #44161536


Source Code Expand

// clang-format off
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REPI,_REP,)(__VA_ARGS__)
#define _RREP(i,n) RREPI(i,n,0)
#define RREPI(i,a,b) for(int i=int(a);i>=int(b);--i)
#define RREP(...) _overload3(__VA_ARGS__,RREPI,_RREP,)(__VA_ARGS__)
#define ALL(a) (a).begin(),(a).end()
#define ALLR(a) (a).rbegin(),(a).rend()
typedef long long ll;
const int INF32 = 1001001001;
const long long INF64 = 1001001001001001001;
struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << setprecision(15); }} init;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<class T> T gcd(T x, T y){ return (x % y) ? gcd(y, x % y) : y; }
template<class T> T lcm(T x, T y){ return x / gcd(x, y) * y; }
template<class T, class... Ts> void output(const T& a, const Ts&... b) { cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }
template<class T> void output(vector<T> v) { for (auto u : v) cout << u << ' '; cout << '\n'; };
void yesno(bool is_ok) { cout << (is_ok ? "yes" : "no") << '\n'; }
void YesNo(bool is_ok) { cout << (is_ok ? "Yes" : "No") << '\n'; }
void YESNO(bool is_ok) { cout << (is_ok ? "YES" : "NO") << '\n'; }

// clang-format on
int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0), b(n, 0);
    REP(i, n - 1) cin >> a[i + 1];
    REP(i, n - 2) cin >> b[i + 2];
    vector<int> dp(n, INF32);
    dp[0] = 0;
    REP(i, 1, n) {
        chmin(dp[i], dp[i - 1] + a[i]);
        if (i - 2 >= 0) chmin(dp[i], dp[i - 2] + b[i]);
    }
    output(dp[n - 1]);
}

Submission Info

Submission Time
Task A16 - Dungeon 1(※初版第 1 刷の B22 も同じ問題です)
User noko206
Language C++ (GCC 9.2.1)
Score 1000
Code Size 1934 Byte
Status AC
Exec Time 25 ms
Memory 4428 KiB

Compile Error

./Main.cpp: In instantiation of ‘void output(const T&, const Ts& ...) [with T = int; Ts = {}]’:
./Main.cpp:45:21:   required from here
./Main.cpp:26:86: warning: statement has no effect [-Wunused-value]
   26 | template<class T, class... Ts> void output(const T& a, const Ts&... b) { cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }
      |                                                                                      ^~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 2
AC × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All large_01.txt, large_02.txt, large_03.txt, max_01.txt, max_02.txt, sample_01.txt, sample_02.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt, small_05.txt, small_06.txt, small_07.txt, small_08.txt, small_09.txt, small_10.txt
Case Name Status Exec Time Memory
large_01.txt AC 17 ms 4404 KiB
large_02.txt AC 19 ms 4156 KiB
large_03.txt AC 14 ms 3868 KiB
max_01.txt AC 16 ms 4428 KiB
max_02.txt AC 25 ms 4296 KiB
sample_01.txt AC 2 ms 3476 KiB
sample_02.txt AC 2 ms 3552 KiB
small_01.txt AC 2 ms 3540 KiB
small_02.txt AC 2 ms 3528 KiB
small_03.txt AC 2 ms 3552 KiB
small_04.txt AC 2 ms 3440 KiB
small_05.txt AC 3 ms 3528 KiB
small_06.txt AC 2 ms 3524 KiB
small_07.txt AC 3 ms 3552 KiB
small_08.txt AC 2 ms 3560 KiB
small_09.txt AC 3 ms 3552 KiB
small_10.txt AC 2 ms 3556 KiB