95892024-02-23 13:32:51TuruTamasMI bróker (50 pont)cpp17Time limit exceeded 4/501.1s6556 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
ifstream in_file("C:\\verseny\\minta\\be1.txt");
#define input in_file
#define INTHENAMEOFGOD
#else
#define input cin
#define INTHENAMEOFGOD \
    ios::sync_with_stdio(0); \
    cin.tie(0); \
    cout.tie(0);
#endif
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<ll, ll> pii;

ll N, Q, V, E, x;
vector<vb> vvb;
vvi h;

int main() {
    INTHENAMEOFGOD
    input >> N >> Q;

    vvb = vector<vb>(500, vb(500, false));
    h = vvi(500, vi(500, 0));
    for (ll n = 0; n < N; n++) {
        input >> x;
        for (V = 0; V < 499; V++) {
            for (E = V+1; E < 500; E++) {
                if (vvb[V][E]) {
                    if (x >= E + 1) {
                        h[V][E] += x;
                        vvb[V][E] = false;
                    }
                } else {
                    if (x <= V + 1) {
                        h[V][E] -= x;
                        vvb[V][E] = true;
                    }
                }
            }
        }
    }
    for (ll q = 0; q < Q; q++) {
        input >> V >> E;
        V--; E--;
        cout << h[V][E] << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/07ms5892 KiB
2Time limit exceeded0/01.1s3348 KiB
3Accepted1/14ms6132 KiB
4Accepted1/16ms6348 KiB
5Accepted2/2524ms6556 KiB
6Time limit exceeded0/21.064s4180 KiB
7Time limit exceeded0/21.047s4672 KiB
8Time limit exceeded0/11.062s4644 KiB
9Time limit exceeded0/11.067s4712 KiB
10Time limit exceeded0/21.074s4788 KiB
11Time limit exceeded0/21.074s4976 KiB
12Time limit exceeded0/21.077s4984 KiB
13Time limit exceeded0/21.046s5084 KiB
14Time limit exceeded0/21.055s5236 KiB
15Time limit exceeded0/31.1s5164 KiB
16Time limit exceeded0/31.062s5164 KiB
17Time limit exceeded0/31.078s5332 KiB
18Time limit exceeded0/31.059s5428 KiB
19Time limit exceeded0/31.067s5560 KiB
20Time limit exceeded0/31.075s5704 KiB
21Time limit exceeded0/31.05s5920 KiB
22Time limit exceeded0/31.082s5812 KiB
23Time limit exceeded0/31.059s5904 KiB
24Time limit exceeded0/31.05s5832 KiB