Submission #1020306

# Submission time Handle Problem Language Result Execution time Memory
1020306 2024-07-11T21:11:57 Z vjudge1 Addk (eJOI21_addk) C++17
36 / 100
2000 ms 3528 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> vec;
    for(;n>0;n--)
    {
        int x;
        cin>>x;
        vec.push_back(x);
    }
    int q;
    cin>>q;
    for(;q>0;q--)
    {
        int x;
        cin>>x;
        if(x==1)
        {
            for(int k1=k;k1>0;k1--)
            {
                int a;
                cin>>a;
            }
        }
        else
        {
            int l,r,m;
            cin>>l>>r>>m;
            l--;
            r--;
            long long p1=l,p2=l,sum=0,res=0;
            for(;p2<m+l;p2++)
            {
                sum=sum+vec[p2];
            }
            p2--;
            for(;p2<=r;p2++,p1++)
            {
                res=res+sum;
                sum=sum-vec[p1];
                if(p2!=vec.size()-1)
                    sum=sum+vec[p2+1];

            }
            cout<<res<<endl;
        }
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:46:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |                 if(p2!=vec.size()-1)
      |                    ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 5 ms 348 KB Output is correct
4 Correct 9 ms 532 KB Output is correct
5 Correct 12 ms 348 KB Output is correct
6 Correct 18 ms 576 KB Output is correct
7 Correct 25 ms 604 KB Output is correct
8 Correct 29 ms 656 KB Output is correct
9 Correct 52 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 181 ms 1364 KB Output is correct
2 Correct 422 ms 1616 KB Output is correct
3 Correct 685 ms 2248 KB Output is correct
4 Execution timed out 2053 ms 3528 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 810 ms 3056 KB Output isn't correct
2 Halted 0 ms 0 KB -