1762021-02-03 22:05:06Babják PéterZenehallgatáscpp11Time limit exceeded 42/50298ms14392 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 < '0' || ch > '9') 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
base42/50
1Accepted0/02ms1748 KiB
2Accepted0/052ms6176 KiB
3Accepted2/22ms3268 KiB
4Accepted2/22ms3288 KiB
5Accepted2/23ms3296 KiB
6Accepted3/317ms3316 KiB
7Accepted3/330ms3332 KiB
8Accepted3/3143ms3372 KiB
9Accepted2/243ms7628 KiB
10Accepted2/241ms8664 KiB
11Accepted2/239ms8764 KiB
12Accepted2/239ms9044 KiB
13Accepted2/241ms9456 KiB
14Accepted2/241ms10768 KiB
15Accepted2/241ms12012 KiB
16Accepted2/245ms13304 KiB
17Accepted2/248ms13812 KiB
18Accepted2/254ms14036 KiB
19Accepted2/265ms14124 KiB
20Accepted2/2165ms14368 KiB
21Time limit exceeded0/2202ms14388 KiB
22Accepted3/3167ms14392 KiB
23Time limit exceeded0/3298ms12160 KiB
24Time limit exceeded0/3238ms12096 KiB