53872023-04-30 17:43:59Laci3000MI bróker (50 pont)cpp17Time limit exceeded 8/501.08s25968 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 = 0;
	
	for (size_t i = 0; i < parameterek; i++)
	{
		bool 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/03ms1824 KiB
2Time limit exceeded0/01.052s3172 KiB
3Accepted1/13ms3064 KiB
4Accepted1/13ms3316 KiB
5Accepted2/23ms3396 KiB
6Accepted2/27ms3560 KiB
7Accepted2/27ms3804 KiB
8Time limit exceeded0/11.065s6068 KiB
9Time limit exceeded0/11.067s7256 KiB
10Time limit exceeded0/21.057s8468 KiB
11Time limit exceeded0/21.08s9928 KiB
12Time limit exceeded0/21.059s11120 KiB
13Time limit exceeded0/21.065s12328 KiB
14Time limit exceeded0/21.065s13396 KiB
15Time limit exceeded0/31.057s14540 KiB
16Time limit exceeded0/31.041s15968 KiB
17Time limit exceeded0/31.044s17288 KiB
18Time limit exceeded0/31.075s18784 KiB
19Time limit exceeded0/31.047s20116 KiB
20Time limit exceeded0/31.047s21548 KiB
21Time limit exceeded0/31.069s22320 KiB
22Time limit exceeded0/31.059s23572 KiB
23Time limit exceeded0/31.059s24828 KiB
24Time limit exceeded0/31.059s25968 KiB