Submission #43727641


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
using mint = modint;

template <class T> struct cumulative_sum {
   public:
    cumulative_sum(int n) : n(n), data(n + 1, 0){};
    cumulative_sum(const vector<T> &v) : n((int)v.size()) {
        data.resize(n + 1, 0);
        for (int i = 0; i < n; ++i) {
            data[i + 1] = v[i];
        }
    };

    void add(int idx, T x) {
        assert(0 <= idx && idx < n);
        data[idx + 1] += x;
    }

    void build() {
        for (int i = 0; i < n; ++i) {
            data[i + 1] += data[i];
        }
    }

    // [l, r)
    T sum(int l, int r) {
        assert(0 <= l && l <= r && r <= n);
        return data[r] - data[l];
    }

   private:
    int n;
    vector<T> data;
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(n - 1);
    REP(i, n - 1) cin >> s[i];
    vector<int> a(m);
    REP(i, m) cin >> a[i];
    cumulative_sum<int> cs(s);
    cs.build();
    int now = 0;
    mint::set_mod(100000);
    mint ans = 0;
    REP(i, m) {
        int l = now;
        int r = now + a[i];
        if (l > r) swap(l, r);
        ans += cs.sum(l, r);
        now += a[i];
    }
    output(ans.val());
}

Submission Info

Submission Time
Task A - 旅人
User noko206
Language C++ (GCC 9.2.1)
Score 20
Code Size 2770 Byte
Status AC
Exec Time 24 ms
Memory 4520 KiB

Compile Error

./Main.cpp: In instantiation of ‘void output(const T&, const Ts& ...) [with T = unsigned int; Ts = {}]’:
./Main.cpp:86: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 set01 set02 set03 set04 set05 set06 set07 set08 set09 set10
Score / Max Score 2 / 2 2 / 2 2 / 2 2 / 2 2 / 2 2 / 2 2 / 2 2 / 2 2 / 2 2 / 2
Status
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
Set Name Test Cases
set01 data1
set02 data2
set03 data3
set04 data4
set05 data5
set06 data6
set07 data7
set08 data8
set09 data9
set10 data10
Case Name Status Exec Time Memory
data1 AC 7 ms 3612 KiB
data10 AC 24 ms 4424 KiB
data2 AC 6 ms 3696 KiB
data3 AC 2 ms 3576 KiB
data4 AC 2 ms 3572 KiB
data5 AC 2 ms 3528 KiB
data6 AC 18 ms 4516 KiB
data7 AC 24 ms 4368 KiB
data8 AC 23 ms 4368 KiB
data9 AC 19 ms 4520 KiB