답안 #689654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689654 2023-01-29T04:50:40 Z zeroesandones Progression (NOI20_progression) C++17
15 / 100
3000 ms 15044 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "

#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back

void solve()
{
    ll n, q;
    cin >> n >> q;

    ll d[n + 1];
    FOR(i, 1, n + 1) {
        cin >> d[i];
    }

    while(q--) {
        int t;
        cin >> t;

        if(t == 1) {
            ll l, r, s, c;
            cin >> l >> r >> s >> c;

            FOR(i, l, r + 1) {
                d[i] += (s + (i - l) * c);
            }
        } else if(t == 2) {
            ll l, r, s, c;
            cin >> l >> r >> s >> c;

            FOR(i, l, r + 1) {
                d[i] = (s + (i - l) * c);
            }
        } else {
            ll l, r;
            cin >> l >> r;

            // how to test the longest subarray with constant change
            if(l == r) {
                cout << 1 << nl;
                continue;
            }

            vi diff;
            FOR(i, l + 1, r + 1) {
               diff.pb(d[i] - d[i - 1]);
            }
            ll ans = 1, cnt = 1;
            FOR(i, 1, diff.size()) {
                if(diff[i] != diff[i - 1]) {
                    cnt = 1;
                } else {
                    ++cnt;
                }

                ans = max(ans, cnt);
            }

            cout << (ans + 1) << nl;
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3035 ms 11416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 354 ms 9480 KB Output is correct
2 Correct 108 ms 2932 KB Output is correct
3 Correct 81 ms 2984 KB Output is correct
4 Correct 71 ms 2964 KB Output is correct
5 Correct 91 ms 3116 KB Output is correct
6 Correct 97 ms 3092 KB Output is correct
7 Correct 96 ms 3276 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3087 ms 10224 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 409 ms 15044 KB Output is correct
2 Correct 88 ms 3520 KB Output is correct
3 Correct 85 ms 3596 KB Output is correct
4 Correct 82 ms 3656 KB Output is correct
5 Correct 100 ms 3656 KB Output is correct
6 Correct 125 ms 3656 KB Output is correct
7 Correct 109 ms 3632 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3076 ms 10644 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 354 ms 9480 KB Output is correct
2 Correct 108 ms 2932 KB Output is correct
3 Correct 81 ms 2984 KB Output is correct
4 Correct 71 ms 2964 KB Output is correct
5 Correct 91 ms 3116 KB Output is correct
6 Correct 97 ms 3092 KB Output is correct
7 Correct 96 ms 3276 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3087 ms 10224 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3035 ms 11416 KB Time limit exceeded
2 Halted 0 ms 0 KB -