1812021-02-03 22:22:13Babják PéterZenehallgatáscpp11Runtime error 0/5092ms18580 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<<1+ result<<3 + (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
base0/50
1Accepted0/02ms1756 KiB
2Runtime error0/068ms18580 KiB
3Wrong answer0/23ms2112 KiB
4Wrong answer0/23ms2104 KiB
5Wrong answer0/23ms2104 KiB
6Wrong answer0/33ms2108 KiB
7Wrong answer0/34ms2104 KiB
8Wrong answer0/33ms2104 KiB
9Runtime error0/275ms18512 KiB
10Runtime error0/275ms18564 KiB
11Runtime error0/275ms18516 KiB
12Runtime error0/274ms18508 KiB
13Runtime error0/270ms18512 KiB
14Runtime error0/270ms18516 KiB
15Runtime error0/270ms18512 KiB
16Runtime error0/271ms18512 KiB
17Runtime error0/272ms18512 KiB
18Runtime error0/270ms18512 KiB
19Runtime error0/270ms18512 KiB
20Runtime error0/292ms18504 KiB
21Runtime error0/271ms18556 KiB
22Runtime error0/370ms18508 KiB
23Runtime error0/370ms18516 KiB
24Runtime error0/371ms18516 KiB