Submission #619461

# Submission time Handle Problem Language Result Execution time Memory
619461 2022-08-02T12:15:10 Z ArsBud Addk (eJOI21_addk) C++14
0 / 100
1477 ms 2616 KB
#include <iostream>

using namespace std;

int N, K, Q, z, n, nuo, iki, sek, ats = 0, sum = 0;
int m[1000005];

int main()
{
//    ios_base::sync_with_stdio(0);
//    cin.tie(nullptr);
//    cout.tie(nullptr);
    cin >> N >> K;
    for(int a = 0; a < N; a++)
    {
        cin >> m[a];
    }
//    for(int a = 0; a < N - 3; a++)
//    {
//        for(int b = a; b < a + 4; b++)
//        {
//            ats += m[b];
//        }
//    }
//    cout << ats;
//    ats = 0;
    cin >> Q;
    for(int a = 0; a < Q; a++)
    {
        cin >> z;
        if(z == 1)
        {
            cin >> n;
            n--;
            int buv = n, p = m[n];
            for(int b = 1; b < K; b++)
            {
                cin >> n;
                n--;
                m[buv] = m[n];
                buv = n;
            }
            m[buv] = p;
        }
        if(z == 2)
        {
            cin >> nuo >> iki >> sek;
            nuo--;
            iki--;
            int pr = 0;
            sum = 0;
            for(int b = nuo; b <= iki; b++)
            {
                sum+= m[b];
                if((b - min(nuo, iki) + 1 >= sek) || ((nuo == 0 && b + nuo + 1 > sek) || (sek == 1 && nuo == iki)))
                {
                    ats += sum - pr;
                    pr += m[b - sek + nuo];
                }
//                cout << "b = " << b << ", min(nuo, iki) = " << min(nuo, iki) << ", m[b] = " << m[b] << ", sum = " << sum << ", pr =  " << pr << ", ats = " << ats << '\n';
            }
            cout << ats << '\n';
            ats = 0;
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 349 ms 1052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1477 ms 2616 KB Output isn't correct
2 Halted 0 ms 0 KB -