54172023-05-16 12:18:12TortelliniJrMI bróker (50 pont)cpp17Time limit exceeded 8/501.1s5856 KiB
#include <vector>
#include <iostream>
#include <array>
using namespace std;

int main()
{
    int inp[2];
    cin >> inp[0] >> inp[1];
    vector<int> v(inp[0]);
    vector<int> b(inp[1]);
    for (int i = 0; i < inp[0]; i++)
    {
        cin >> v[i];
    }
    vector<pair<int, int>> p(inp[1]);
    for (int i = 0; i < inp[1]; i++)
    {
        cin >> p[i].first >> p[i].second;
    }
    vector<int> e(inp[1]);
    for (int i = 0; i < inp[0]; i++)
    {
        for (int u = 0; u < inp[1]; u++)
        {
            if (e[u] == 0 && v[i] <= p[u].first)
            {
                e[u] = v[i];
                b[u] -= v[i];
            }
            else if (e[u] != 0 && v[i] >= p[u].second)
            {
                e[u] = 0;
                b[u] += v[i];
            }
        }
    }
    for (int i = 0; i < inp[1]; i++)
    {
        cout << b[i] << endl;
    }
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms2088 KiB
2Time limit exceeded0/01.1s2740 KiB
3Accepted1/13ms2264 KiB
4Accepted1/13ms2468 KiB
5Accepted2/23ms2588 KiB
6Accepted2/28ms2596 KiB
7Accepted2/28ms2916 KiB
8Time limit exceeded0/11.1s4676 KiB
9Time limit exceeded0/11.065s4748 KiB
10Time limit exceeded0/21.054s4752 KiB
11Time limit exceeded0/21.057s4772 KiB
12Time limit exceeded0/21.062s5004 KiB
13Time limit exceeded0/21.072s5108 KiB
14Time limit exceeded0/21.024s5380 KiB
15Time limit exceeded0/31.047s5408 KiB
16Time limit exceeded0/31.067s5684 KiB
17Time limit exceeded0/31.067s5676 KiB
18Time limit exceeded0/31.064s5416 KiB
19Time limit exceeded0/31.072s5420 KiB
20Time limit exceeded0/31.059s5704 KiB
21Time limit exceeded0/31.08s5700 KiB
22Time limit exceeded0/31.052s5576 KiB
23Time limit exceeded0/31.075s5600 KiB
24Time limit exceeded0/31.067s5856 KiB