1732021-02-03 21:59:35kovacs.peter.18fKéséscpp11Wrong answer 0/5041ms11764 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct time_ {
	int second;
	int index;
	int song;
};

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

	int N, K;
	cin >> N >> K;
	vector<int> songS(N);
	int full_time = 0;
	for (auto& e : songS) {
		cin >> e;
		full_time += e;
	}
	vector<time_> timeS(K);
	for (int i = 0; i < K; i++) {
		cin >> timeS[i].second;
		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
base0/50
1Accepted0/02ms1780 KiB
2Accepted0/04ms2304 KiB
3Wrong answer0/51ms1948 KiB
4Wrong answer0/51ms1960 KiB
5Wrong answer0/517ms4072 KiB
6Wrong answer0/516ms4840 KiB
7Wrong answer0/425ms6632 KiB
8Wrong answer0/424ms7764 KiB
9Wrong answer0/437ms11108 KiB
10Wrong answer0/435ms10680 KiB
11Wrong answer0/441ms11764 KiB
12Runtime error0/228ms9008 KiB
13Runtime error0/228ms9012 KiB
14Runtime error0/128ms9008 KiB
15Runtime error0/128ms9008 KiB
16Runtime error0/134ms9004 KiB
17Runtime error0/132ms9012 KiB
18Runtime error0/129ms9004 KiB
19Runtime error0/129ms9008 KiB