THPTQH_DODEP - ĐÀ NẴNG ĐỘ ĐẸP

Xem dạng PDF

Gửi bài giải


Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: DODEP.INP
Output: DODEP.OUT

Tác giả:
Dạng bài
Ngôn ngữ cho phép
C, C#, C++, Go, Java, JavaScript, Kotlin, Pascal, Perl, PHP, PyPy, Python, Ruby, Rust, Scratch, Swift


Bình luận

Please read the guidelines before commenting.



  • 0
    ToiNhoDuongThanhThao  đã bình luận lúc 11, Tháng 6, 2026, 3:55

    include <iostream>

    include <vector>

    include <fstream>

    using namespace std;

    int main() { iosbase::syncwith_stdio(false); cin.tie(NULL);

    ifstream fi("DODEP.INP");
    ofstream fo("DODEP.OUT");
    
    int n, q;
    fi >> n >> q;
    
    vector&lt;long long> a(n);
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        fi >> a[i];
        sum += a[i];
    }
    
    int offset = 0; 
    
    while (q--) {
        int type;
        fi >> type;
        if (type == 1) {
            int i;
            long long x;
            fi >> i >> x;
            int pos = (i - 1 + offset) % n;
            sum = sum - a[pos] + x;
            a[pos] = x;
            fo << sum << "\n";
        } else {
            int k;
            fi >> k;
            offset = (offset - (k % n) + n) % n;
        }
    }
    
    fi.close();
    fo.close();
    return 0;
    

    }