就差0.01s,求助TLE!

P2801 教主的魔法

dingshengyang @ 2022-01-31 19:39:47

#include <bits/stdc++.h>
#define R register
#define inl inline
#define fastios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define Debug(file) freopen(file".in","r",stdin);freopen(file".out","w",stdout);
/*洛谷万岁*/
using namespace std;
const int N = 1e6 + 5;
int* a = new int[N];
int main() {
    R int n,q,t,ans;
    fastios;
    cin >> n >> q;
    for(R int i = 1;i + 3 <= n;i += 4){
        cin >> a[i] >> a[i+1] >> a[i+2] >> a[i+3];t = i+3;
    }
    for(++t;t <= n;++ t)cin >> a[t];
    while(q--){
        R char op;R int l,r,c;
        cin >> op >> l >> r >> c;t = l - 1;
        if(op == 'M'){
            for(R int i = l;i + 3 <= r;i += 4){
                a[i] += c;a[i+1] += c;a[i+2] += c;a[i+3] += c;t = i + 3;
            }
            for(++t;t <= r;++ t)a[t] += c;
        }
        if(op == 'A'){
            ans = 0;
            for(R int i = l;i + 3 <= r;i += 4){
                t = i + 3;
                ans += (a[i]>=c)+(a[i+1]>=c)+(a[i+2]>=c)+(a[i+3]>=c);
            }
            for(++t;t <= r;++ t)ans += (a[t] >= c);
            cout << ans << endl;
        }
    }
    return 0;
}

by Hollis_Yang @ 2022-01-31 19:40:58

加个快读呗


by dingshengyang @ 2022-01-31 19:42:26

@htssm 话说,卡常是真的NB


by Misaka_Mik0t0 @ 2022-01-31 19:48:02

深夜评测是个好东西,过几个小时再交应该就能过了。


|