95032024-02-22 12:33:06MagyarKendeSZLGMI bróker (50 pont)cpp17Time limit exceeded 8/501.1s4084 KiB
#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define size(v) (int)v.size()

using namespace std;
using ll = long long;

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

    int N, Q;
    cin >> N >> Q;

    vector<int> priceS(N);
    for (int i = 0; i < N; i++) {
        cin >> priceS[i];
    }

    while (Q--) {
        int result = 0;

        bool has = 0;

        int V, E;
        cin >> V >> E;

        for (int i = 0; i < N; i++) {
            if (!has && V >= priceS[i]) {
                has = 1;
                result -= priceS[i];
            }
            else if (has && E <= priceS[i]) {
                has = 0;
                result += priceS[i];
            }
        }

        cout << result << '\n';
    }
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1832 KiB
2Time limit exceeded0/01.1s1444 KiB
3Accepted1/13ms2136 KiB
4Accepted1/13ms2256 KiB
5Accepted2/23ms2488 KiB
6Accepted2/26ms2848 KiB
7Accepted2/26ms3036 KiB
8Time limit exceeded0/11.1s2380 KiB
9Time limit exceeded0/11.049s3140 KiB
10Time limit exceeded0/21.07s2596 KiB
11Time limit exceeded0/21.074s3252 KiB
12Time limit exceeded0/21.049s3292 KiB
13Time limit exceeded0/21.065s3304 KiB
14Time limit exceeded0/21.072s3440 KiB
15Time limit exceeded0/31.065s2616 KiB
16Time limit exceeded0/31.067s2856 KiB
17Time limit exceeded0/31.082s3624 KiB
18Time limit exceeded0/31.042s3640 KiB
19Time limit exceeded0/31.062s3060 KiB
20Time limit exceeded0/31.077s2928 KiB
21Time limit exceeded0/31.1s3796 KiB
22Time limit exceeded0/31.074s3096 KiB
23Time limit exceeded0/31.065s3796 KiB
24Time limit exceeded0/31.042s4084 KiB