結果

問題 No.1219 Mancala Combo
ユーザー 👑 rin204rin204
提出日時 2022-07-04 15:31:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,114 bytes
コンパイル時間 2,322 ms
コンパイル使用メモリ 205,040 KB
実行使用メモリ 13,716 KB
最終ジャッジ日時 2023-08-20 23:07:00
合計ジャッジ時間 7,972 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,768 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 7 ms
4,384 KB
testcase_05 AC 4 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 4 ms
4,388 KB
testcase_08 AC 4 ms
4,384 KB
testcase_09 AC 2 ms
4,388 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/lazysegtree>
using namespace std;
using namespace atcoder;
const int inf = 1 << 30;

struct S{
    int ind;
    int min_;
};
using F = int;

S e(){
    return S{-1, inf};
}

S op(S l, S r){
    if(l.min_ <= r.min_) return l;
    else return r;
}

S mapping(F l, S r){
    return S({r.ind, r.min_ + l});
}

F composition(F l, F r){
    return l + r;
}

F id(){
    return 0;
}

void solve(){
    int n, a;
    cin >> n;
    vector<S> A(n);
    for(int i = 0; i < n; i++){
        cin >> a;
        A[i].ind = i;
        A[i].min_ = i + 1 - a;
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(A);
    while(1){
        S tmp = seg.prod(0, n);
        if(tmp.min_ != 0) break;
        seg.apply(0, tmp.ind, -1);
        seg.apply(tmp.ind, tmp.ind + 1, tmp.ind + 1);
    }
    for(int i = 0; i < n; i++){
        if(seg.get(i).min_ != i + 1){
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
    
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    int t;
    t = 1;
    //cin >> t;
    while(t--) solve();
}
    
    


0