답안 #834257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
834257 2023-08-22T12:22:21 Z unnick Progression (NOI20_progression) C++14
0 / 100
3000 ms 9824 KB
#include <iostream>
#include <vector>
using namespace std;
int main(){
    // The following line disables syncing between cin/scanf and cout/printf.
    // It makes input faster, but you must not use functions from <cstdio> (e.g. scanf/printf) directly.
    // This line must be executed before any use of cin/cout.
    ios_base::sync_with_stdio(false);

    // Your code goes here ...
    // (You can now read input and write output normally using cin/cout.)
    int N,Q;
    cin >> N >> Q;
    std::vector<int> arr;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        arr.push_back(tmp);
    }
    for (int q = 0; q < Q; q++) {
        int op;
        cin >> op;
        int l,r,s,c;
        switch (op) {
        case 1:
            cin >> l >> r >> s >> c;
            for(int i = l; i <= r; i++) {
                arr[i-1] += s+(i-l)*c;
            }
            break;
        case 2:
            cin >> l >> r >> s >> c;
            for(int i = l; i <= r; i++) {
                arr[i-1] = s+(i-l)*c;
            }
            break;
        case 3:
            cin >> l >> r;
            // cout << "\n-- ";
            // for (int i = 0; i < N; i++) {
            //     cout << arr[i] << " ";
            // }
            // cout << '\n';
            if (l == r) {
                cout << 1;
                break;
            }
            int maxl = 1;
            int len = 0;
            int d = -1000000000;
            for (int i = l-1+1; i < r; i++) {
                int cd = arr[i] - arr[i-1];
                if (d != cd) {
                    if (maxl < len) maxl = len;
                    len = 1;
                    d = cd;
                } else len++;
            }
            if (maxl < len) maxl = len;
            cout << (maxl+1) << endl;
            break;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3022 ms 3148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 411 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 324 ms 9824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 411 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3022 ms 3148 KB Time limit exceeded
2 Halted 0 ms 0 KB -