Submission #7036758


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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/









int N; ll K; ll A[151010]; ll v[4][151010];
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
    rep(i, 0, N - (K - 1) * 2) {
        if (0 < i) {
            v[1][i] = v[0][i] + v[1][i - 1];
            v[2][i] = v[1][i] + v[2][i - 1];
            v[3][i] = v[2][i] + v[3][i - 1];
        }

        ll rest = A[i] - v[3][i];
        if(rest < 0) return no;

        v[0][i] += rest;
        v[1][i] += rest;
        v[2][i] += rest;
        v[3][i] += rest;
        v[0][i + 1] += rest;
        v[0][i + 1 + 1 + K - 2] -= rest * 4 * K;
        v[0][i + 1 + 1 + K - 2 + 1] += rest * 4 * K;
        v[0][i + 1 + 1 + K - 2 + 1 + 1 + K - 2] -= rest;
        v[0][i + 1 + 1 + K - 2 + 1 + 1 + K - 2 + 1] -= rest;
    }

    rep(i, N - (K - 1) * 2, N) {
        if (0 < i) {
            v[1][i] = v[0][i] + v[1][i - 1];
            v[2][i] = v[1][i] + v[2][i - 1];
            v[3][i] = v[2][i] + v[3][i - 1];
        }

        if(A[i] != v[3][i]) return no;
    }

    return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];
    cout << solve() << endl;
}





Submission Info

Submission Time
Task F - Segtree☆Magica
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 700
Code Size 2523 Byte
Status AC
Exec Time 18 ms
Memory 5760 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 200 / 200 500 / 500
Status
AC × 3
AC × 32
AC × 57
Set Name Test Cases
Sample Sample_01.txt, Sample_02.txt, Sample_03.txt
Subtask1 Sample_01.txt, Sample_02.txt, Sample_03.txt, subtask0_01.txt, subtask0_02.txt, subtask0_03.txt, subtask0_04.txt, subtask0_05.txt, subtask0_06.txt, subtask0_07.txt, subtask0_08.txt, subtask0_09.txt, subtask0_10.txt, subtask0_11.txt, subtask0_12.txt, subtask0_13.txt, subtask0_14.txt, subtask0_15.txt, subtask0_16.txt, subtask0_17.txt, subtask0_18.txt, subtask0_19.txt, subtask0_20.txt, subtask0_21.txt, subtask0_22.txt, subtask0_23.txt, subtask0_24.txt, subtask0_25.txt, angel_01.txt, small_killer_01.txt, small_killer_02.txt, small_killer_03.txt
Subtask2 Sample_01.txt, Sample_02.txt, Sample_03.txt, subtask0_01.txt, subtask0_02.txt, subtask0_03.txt, subtask0_04.txt, subtask0_05.txt, subtask0_06.txt, subtask0_07.txt, subtask0_08.txt, subtask0_09.txt, subtask0_10.txt, subtask0_11.txt, subtask0_12.txt, subtask0_13.txt, subtask0_14.txt, subtask0_15.txt, subtask0_16.txt, subtask0_17.txt, subtask0_18.txt, subtask0_19.txt, subtask0_20.txt, subtask0_21.txt, subtask0_22.txt, subtask0_23.txt, subtask0_24.txt, subtask0_25.txt, angel_01.txt, small_killer_01.txt, small_killer_02.txt, small_killer_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, large_killer_01.txt, large_killer_02.txt, large_killer_03.txt
Case Name Status Exec Time Memory
Sample_01.txt AC 2 ms 2304 KB
Sample_02.txt AC 2 ms 2304 KB
Sample_03.txt AC 2 ms 2304 KB
angel_01.txt AC 2 ms 2304 KB
large_killer_01.txt AC 16 ms 4608 KB
large_killer_02.txt AC 18 ms 4608 KB
large_killer_03.txt AC 16 ms 4608 KB
small_killer_01.txt AC 2 ms 2304 KB
small_killer_02.txt AC 2 ms 2304 KB
small_killer_03.txt AC 2 ms 2304 KB
subtask0_01.txt AC 2 ms 2304 KB
subtask0_02.txt AC 2 ms 2304 KB
subtask0_03.txt AC 2 ms 2304 KB
subtask0_04.txt AC 2 ms 2304 KB
subtask0_05.txt AC 2 ms 2304 KB
subtask0_06.txt AC 2 ms 2304 KB
subtask0_07.txt AC 2 ms 2304 KB
subtask0_08.txt AC 2 ms 2304 KB
subtask0_09.txt AC 2 ms 2304 KB
subtask0_10.txt AC 2 ms 2304 KB
subtask0_11.txt AC 2 ms 2304 KB
subtask0_12.txt AC 2 ms 2304 KB
subtask0_13.txt AC 2 ms 2304 KB
subtask0_14.txt AC 2 ms 2304 KB
subtask0_15.txt AC 2 ms 2304 KB
subtask0_16.txt AC 2 ms 2304 KB
subtask0_17.txt AC 2 ms 2304 KB
subtask0_18.txt AC 2 ms 2304 KB
subtask0_19.txt AC 2 ms 2304 KB
subtask0_20.txt AC 2 ms 2304 KB
subtask0_21.txt AC 2 ms 2304 KB
subtask0_22.txt AC 2 ms 2304 KB
subtask0_23.txt AC 2 ms 2304 KB
subtask0_24.txt AC 2 ms 2304 KB
subtask0_25.txt AC 2 ms 2304 KB
subtask1_01.txt AC 17 ms 5632 KB
subtask1_02.txt AC 17 ms 5632 KB
subtask1_03.txt AC 17 ms 5632 KB
subtask1_04.txt AC 17 ms 5632 KB
subtask1_05.txt AC 17 ms 5632 KB
subtask1_06.txt AC 17 ms 5632 KB
subtask1_07.txt AC 17 ms 5632 KB
subtask1_08.txt AC 17 ms 5632 KB
subtask1_09.txt AC 17 ms 5632 KB
subtask1_10.txt AC 17 ms 5632 KB
subtask1_11.txt AC 16 ms 4608 KB
subtask1_12.txt AC 16 ms 4608 KB
subtask1_13.txt AC 16 ms 4608 KB
subtask1_14.txt AC 16 ms 4608 KB
subtask1_15.txt AC 16 ms 4608 KB
subtask1_16.txt AC 17 ms 4608 KB
subtask1_17.txt AC 16 ms 4608 KB
subtask1_18.txt AC 17 ms 4608 KB
subtask1_19.txt AC 16 ms 4608 KB
subtask1_20.txt AC 16 ms 4608 KB
subtask1_21.txt AC 11 ms 5760 KB
subtask1_22.txt AC 16 ms 4736 KB