1802021-02-03 22:21:01Babják PéterZenehallgatáscpp11Time limit exceeded 44/50291ms6936 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-48;
	ch = getchar();
	while (ch >32) {
		result = result*10 + (ch - 48);
		ch = getchar();
	}
		return result;
}
int main() {
	ios_base::sync_with_stdio(false);cout.tie(NULL);
	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/02ms1768 KiB
2Accepted0/037ms5236 KiB
3Accepted2/22ms2308 KiB
4Accepted2/22ms2300 KiB
5Accepted2/23ms2300 KiB
6Accepted3/314ms2344 KiB
7Accepted3/328ms2348 KiB
8Accepted3/3131ms2340 KiB
9Accepted2/248ms5236 KiB
10Accepted2/235ms5672 KiB
11Accepted2/237ms5936 KiB
12Accepted2/237ms5912 KiB
13Accepted2/235ms5916 KiB
14Accepted2/239ms5940 KiB
15Accepted2/239ms5932 KiB
16Accepted2/243ms5936 KiB
17Accepted2/252ms5932 KiB
18Accepted2/250ms6488 KiB
19Accepted2/250ms6632 KiB
20Accepted2/2159ms6632 KiB
21Accepted2/2168ms6784 KiB
22Accepted3/3160ms6936 KiB
23Time limit exceeded0/3282ms4740 KiB
24Time limit exceeded0/3291ms4832 KiB