Submission #909359

# Submission time Handle Problem Language Result Execution time Memory
909359 2024-01-17T07:32:41 Z danikoynov Progression (NOI20_progression) C++14
0 / 100
3000 ms 15184 KB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
const int maxn = 3e5 + 10;

int n, q;
ll d[maxn], b[maxn];

void input()
{
    cin >> n >> q;
    for (int i = 1; i <= n; i ++)
    {
        cin >> d[i];
        b[i] = d[i] - d[i - 1];
    }
}

int query(int l, int r)
{
    if (l == r)
        return 1;

    int cnt = 1, mx = 0;
    for (int i = l + 2; i <= r; i ++)
    {
        if (b[i] == b[i -1])
            cnt ++;
        else
        {
            if (cnt > mx)
                mx = cnt;
            cnt = 1;
        }
    }
    if (cnt > mx)
        mx = cnt;
    return mx + 1;
}
void simulate()
{
    for (int i = 1; i <= q; i ++)
    {
        int type, l, r;
        ll s, c;
        cin >> type >> l >> r;
        if (type == 3)
        {
            cout << query(l, r) << endl;
        }
        else if (type == 1)
        {
            cin >> s >> c;
            for (int j = l; j <= r; j ++)
            {
                d[j] += s + (ll)(j - l) * c;
            }
            b[l] += s;
            for (int j = l + 1; j <= r; j ++)
                b[j] += c;
            b[r + 1] = d[r + 1] - d[r - 1];
        }
        else
        {
            cin >> s >> c;
            for (int j = l; j <= r; j ++)
            {
                d[j] = s + (ll)(j - l) * c;
            }
            for (int j = l + 1; j <= r; j ++)
                b[j] = c;
            b[l] = d[l] - d[l - 1];
            b[r + 1] = d[r + 1] - d[r];
        }

        /**for (int j = 1; j <= n; j ++)
        {

            b[j] = d[j] - d[j - 1];
        }*/
        /**for (int j = 1; j <= n; j ++)
            cout << d[j] << " ";
        cout << endl;*/
    }
}
void solve()
{
    input();
    simulate();
}

int main()
{
    speed();
    solve();
    return 0;
}

# Verdict Execution time Memory Grader output
1 Execution timed out 3039 ms 7836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 122 ms 12144 KB Output is correct
2 Correct 61 ms 5144 KB Output is correct
3 Correct 57 ms 4948 KB Output is correct
4 Correct 54 ms 4944 KB Output is correct
5 Correct 61 ms 5220 KB Output is correct
6 Correct 57 ms 5188 KB Output is correct
7 Correct 58 ms 5260 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Execution timed out 3058 ms 6724 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 15184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 122 ms 12144 KB Output is correct
2 Correct 61 ms 5144 KB Output is correct
3 Correct 57 ms 4948 KB Output is correct
4 Correct 54 ms 4944 KB Output is correct
5 Correct 61 ms 5220 KB Output is correct
6 Correct 57 ms 5188 KB Output is correct
7 Correct 58 ms 5260 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Execution timed out 3058 ms 6724 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3039 ms 7836 KB Time limit exceeded
2 Halted 0 ms 0 KB -