96042024-02-23 14:12:48TuruTamasMI bróker (50 pont)cpp17Time limit exceeded 8/501.1s17092 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;
set<pii> sp;
vector<pii> vp;
vvi h;
vi a;

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

    vvb = vector<vb>(500, vb(500, false));
    h = vvi(500, vi(500, 0));
    a.resize(N);
    for (ll n = 0; n < N; n++) {
        input >> a[n];
    }
    for (ll q = 0; q < Q; q++) {
        input >> V >> E;
        V--; E--;
        sp.emplace(V, E);
        vp.emplace_back(V, E);
    }
    for (ll x : a) {
        for (auto [V, E] : sp) {
            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 (auto [V, E] : vp) {
        cout << h[V][E] << "\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/04ms5756 KiB
2Time limit exceeded0/01.067s10468 KiB
3Accepted1/14ms6316 KiB
4Accepted1/14ms6528 KiB
5Accepted2/24ms6776 KiB
6Accepted2/28ms7048 KiB
7Accepted2/28ms7004 KiB
8Time limit exceeded0/11.1s15516 KiB
9Time limit exceeded0/11.075s15412 KiB
10Time limit exceeded0/21.055s15556 KiB
11Time limit exceeded0/21.044s13824 KiB
12Time limit exceeded0/21.067s15736 KiB
13Time limit exceeded0/21.072s15868 KiB
14Time limit exceeded0/21.064s13780 KiB
15Time limit exceeded0/31.07s14128 KiB
16Time limit exceeded0/31.083s14012 KiB
17Time limit exceeded0/31.072s15904 KiB
18Time limit exceeded0/31.052s16196 KiB
19Time limit exceeded0/31.067s14624 KiB
20Time limit exceeded0/31.05s14692 KiB
21Time limit exceeded0/31.075s16560 KiB
22Time limit exceeded0/31.064s16916 KiB
23Time limit exceeded0/31.072s17092 KiB
24Time limit exceeded0/31.055s16920 KiB