Submission #4312713


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<typename T> struct Ruisekiwa {
    vector<T> v;
    int n;
    Ruisekiwa() {}
    Ruisekiwa(T* beg, T* end) { init(beg, end); }
    void init(T* beg, T* end) {
        n = end - beg;
        v.resize(0);
        v.clear();
        v.resize(n, 0);
        v[0] = beg[0];
        rep(i, 1, n) v[i] = beg[i] + v[i - 1];
    }
    T get(int L, int R) { // [L,R)
        R = min(R, n);
        if (n <= L) return 0;
        if (L >= R) return 0;
        
        T res = v[R - 1];
        if (0 < L) res -= v[L - 1];
        return res;
    }
};
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/






int N;
ll A[3010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    Ruisekiwa<ll> rui(A, A + N);
    rep(k, 1, N + 1) {
        ll ans = -1;
        rep(i, 0, N) chmax(ans, rui.get(i, i + k));
        cout << ans << endl;
    }
}

Submission Info

Submission Time
Task A - Abundant Resources
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 200
Code Size 2188 Byte
Status
Exec Time 24 ms
Memory 384 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt
All 200 / 200 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, sample-01.txt, sample-02.txt, sample-03.txt
Case Name Status Exec Time Memory
01-01.txt 1 ms 256 KB
01-02.txt 3 ms 256 KB
01-03.txt 3 ms 256 KB
01-04.txt 13 ms 384 KB
01-05.txt 14 ms 384 KB
01-06.txt 14 ms 384 KB
01-07.txt 17 ms 384 KB
01-08.txt 24 ms 384 KB
01-09.txt 24 ms 384 KB
01-10.txt 24 ms 384 KB
sample-01.txt 1 ms 256 KB
sample-02.txt 1 ms 256 KB
sample-03.txt 1 ms 256 KB