1832021-02-03 22:24:18Babják PéterZenehallgatáscpp11Time limit exceeded 44/50298ms4780 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
base44/50
1Accepted0/02ms1756 KiB
2Accepted0/037ms4776 KiB
3Accepted2/22ms1860 KiB
4Accepted2/22ms1860 KiB
5Accepted2/23ms1864 KiB
6Accepted3/316ms1864 KiB
7Accepted3/329ms1864 KiB
8Accepted3/3138ms1892 KiB
9Accepted2/239ms4772 KiB
10Accepted2/239ms4776 KiB
11Accepted2/237ms4760 KiB
12Accepted2/239ms4772 KiB
13Accepted2/237ms4768 KiB
14Accepted2/239ms4776 KiB
15Accepted2/241ms4768 KiB
16Accepted2/241ms4780 KiB
17Accepted2/245ms4772 KiB
18Accepted2/248ms4780 KiB
19Accepted2/248ms4776 KiB
20Accepted2/2165ms4776 KiB
21Accepted2/2160ms4768 KiB
22Accepted3/3162ms4772 KiB
23Time limit exceeded0/3298ms2636 KiB
24Time limit exceeded0/3291ms2512 KiB