94192024-02-21 14:41:01AblablablaMI bróker (50 pont)cpp17Time limit exceeded 8/501.1s4712 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, q;
    cin >> n >> q;

    vector<int> a(n);
    for(int &x : a){
        cin >> x;
    }

    while(q--){
        int v, e;
        cin >> v >> e;

        int nyereseg = 0;
        bool birtokol = 0;

        for(int i = 0; i < n; i++){
            if(!birtokol && a[i] <= v){
                nyereseg -= a[i];
                birtokol = 1;
            } else if(birtokol && a[i] >= e){
                nyereseg += a[i];
                birtokol = 0;
            }
        }

        cout << nyereseg << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1828 KiB
2Time limit exceeded0/01.1s1384 KiB
3Accepted1/13ms2568 KiB
4Accepted1/13ms2760 KiB
5Accepted2/23ms2824 KiB
6Accepted2/26ms3200 KiB
7Accepted2/26ms3152 KiB
8Time limit exceeded0/11.1s2652 KiB
9Time limit exceeded0/11.047s2896 KiB
10Time limit exceeded0/21.062s3696 KiB
11Time limit exceeded0/21.065s3972 KiB
12Time limit exceeded0/21.075s4164 KiB
13Time limit exceeded0/21.082s4244 KiB
14Time limit exceeded0/21.026s4244 KiB
15Time limit exceeded0/31.067s4168 KiB
16Time limit exceeded0/31.074s3632 KiB
17Time limit exceeded0/31.07s4332 KiB
18Time limit exceeded0/31.05s4384 KiB
19Time limit exceeded0/31.062s4632 KiB
20Time limit exceeded0/31.067s4604 KiB
21Time limit exceeded0/31.065s4712 KiB
22Time limit exceeded0/31.07s3936 KiB
23Time limit exceeded0/31.031s4608 KiB
24Time limit exceeded0/31.054s4664 KiB