1712021-02-03 21:56:49kovacs.peter.18fKéséscpp11Wrong answer 0/5041ms26188 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/04ms2236 KiB
3Wrong answer0/51ms1952 KiB
4Wrong answer0/51ms1960 KiB
5Wrong answer0/517ms4076 KiB
6Wrong answer0/517ms4844 KiB
7Wrong answer0/425ms6640 KiB
8Wrong answer0/425ms7892 KiB
9Wrong answer0/439ms11288 KiB
10Wrong answer0/435ms12124 KiB
11Wrong answer0/441ms14452 KiB
12Runtime error0/227ms13744 KiB
13Runtime error0/228ms15708 KiB
14Runtime error0/128ms17664 KiB
15Runtime error0/127ms19632 KiB
16Runtime error0/128ms21492 KiB
17Runtime error0/137ms23456 KiB
18Runtime error0/128ms24240 KiB
19Runtime error0/128ms26188 KiB