1772021-02-03 22:12:48Babják PéterZenehallgatáscpp11Time limit exceeded 44/50296ms4736 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct time_ {
	int second;
	int index;
	int song;
};
int read() {
	int result = 0;
	char ch;
	ch = getchar();
	result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch ==10 || ch == 32) break;
		result = result*10 + (ch - '0');
	}
		return result;
}
int main() {

	int N, K;
	N=read();K=read();
	vector<int> songS(N);
	int full_time = 0;
	for (auto& e : songS) {
		e=read();
		full_time += e;
	}
	vector<time_> timeS(K);
	for (int i = 0; i < K; i++) {
		timeS[i].second=read();
		timeS[i].index = i;
	}
	sort(timeS.begin(), timeS.end(), [](time_ a, time_ b) {
		return a.second < b.second;
	});
	int song = 0;
	long long length = songS[0];
	for (auto& e : timeS) {
		while (e.second > length) {
			song = (song == N - 1 ? 0 : song + 1);
			length += songS[song];
		}
		e.song = song + 1;
	}
	sort(timeS.begin(), timeS.end(), [](time_ a, time_ b) {
		return a.index < b.index;
	});
	for (auto e : timeS) {
		cout << e.song << " ";
	}
}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/02ms1740 KiB
2Accepted0/039ms4636 KiB
3Accepted2/21ms1836 KiB
4Accepted2/22ms1840 KiB
5Accepted2/23ms1840 KiB
6Accepted3/316ms1840 KiB
7Accepted3/328ms1840 KiB
8Accepted3/3150ms1860 KiB
9Accepted2/239ms4696 KiB
10Accepted2/239ms4696 KiB
11Accepted2/239ms4696 KiB
12Accepted2/243ms4696 KiB
13Accepted2/241ms4700 KiB
14Accepted2/243ms4700 KiB
15Accepted2/243ms4696 KiB
16Accepted2/245ms4700 KiB
17Accepted2/246ms4700 KiB
18Accepted2/256ms4696 KiB
19Accepted2/254ms4696 KiB
20Accepted2/2167ms4732 KiB
21Accepted2/2168ms4732 KiB
22Accepted3/3172ms4736 KiB
23Time limit exceeded0/3296ms2448 KiB
24Time limit exceeded0/3286ms2444 KiB