53882023-04-30 17:49:30Laci3000MI bróker (50 pont)cpp17Time limit exceeded 8/501.1s5396 KiB
// nt2020 masodik.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <vector>
#include <iostream>

using namespace std;



void fak_es_a_bagoly() {
	int trees, distance;
	cin >> trees >> distance;
	vector<int> listS(trees);
	for (size_t i = 0; i < trees; i++)
	{
		cin >> listS[i];
	}
	int helyzetem = 0, i;
    for (size_t i = 0; i < helyzetem + distance + 1 && i < trees; i++)
	{
		if (listS[i] > listS[helyzetem]) {
			helyzetem = i;
		}
	}
	cout << ++helyzetem << '\n';
}

void MI_broker() {
	int secs, parameterek;
	cin >> secs >> parameterek;
	vector<int> dataS(secs);
	vector<pair<int, int>> parameterS(parameterek);
	for (size_t i = 0; i < secs; i++)
	{
		cin >> dataS[i];
	}for (size_t i = 0; i < parameterek; i++)
	{
		cin >> parameterS[i].first >> parameterS[i].second;
	}
	vector<int> jovedelmek(parameterek);
	int actual;
	bool van_e;
	for (size_t i = 0; i < parameterek; i++)
	{
		van_e = false;
		actual = 0;
		for (size_t a = 0; a < secs; a++)
		{
			if (dataS[a] <= parameterS[i].first && !van_e) {
				van_e = true;
				actual -= dataS[a];
			}
			else if (parameterS[i].second <= dataS[a] && van_e) {
				actual += dataS[a];
				van_e = false;
			}
		}
		jovedelmek[i] = actual;
	}
	for (size_t i = 0; i < parameterek; i++)
	{
		cout << jovedelmek[i] << '\n';
	}
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(nullptr);
	MI_broker();
}

SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1828 KiB
2Time limit exceeded0/01.1s2416 KiB
3Accepted1/13ms2272 KiB
4Accepted1/13ms2484 KiB
5Accepted2/23ms2664 KiB
6Accepted2/27ms2924 KiB
7Accepted2/27ms3156 KiB
8Time limit exceeded0/11.1s4228 KiB
9Time limit exceeded0/11.057s4384 KiB
10Time limit exceeded0/21.062s4684 KiB
11Time limit exceeded0/21.065s4956 KiB
12Time limit exceeded0/21.052s5004 KiB
13Time limit exceeded0/21.077s5076 KiB
14Time limit exceeded0/21.06s5264 KiB
15Time limit exceeded0/31.042s4836 KiB
16Time limit exceeded0/31.078s4924 KiB
17Time limit exceeded0/31.054s5068 KiB
18Time limit exceeded0/31.023s4952 KiB
19Time limit exceeded0/31.085s4992 KiB
20Time limit exceeded0/31.054s4900 KiB
21Time limit exceeded0/31.072s4976 KiB
22Time limit exceeded0/31.069s4968 KiB
23Time limit exceeded0/31.06s5168 KiB
24Time limit exceeded0/31.065s5396 KiB