1722021-02-03 21:57:28Babják PéterZenehallgatáscpp11Time limit exceeded 44/50293ms12984 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct time_ {
	int second;
	int index;
	int song;
};
long long int read(){
	char r;
	bool start=false;
	long long int ret=0;
	while(true){
		r=getchar();
		if((r-'0'<0 || r-'0'>9) && !start){
			continue;
		}
		if((r-'0'<0 || r-'0'>9) && start){
			break;
		}
		if(start)ret*=10;
		start=true;
		ret+=r-'0';
	}
		return ret;}
int main() {

	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/02ms1740 KiB
2Accepted0/039ms6064 KiB
3Accepted2/21ms3276 KiB
4Accepted2/22ms3296 KiB
5Accepted2/23ms3316 KiB
6Accepted3/316ms3324 KiB
7Accepted3/329ms3340 KiB
8Accepted3/3125ms3376 KiB
9Accepted2/239ms7640 KiB
10Accepted2/248ms8328 KiB
11Accepted2/241ms9628 KiB
12Accepted2/241ms10868 KiB
13Accepted2/241ms11584 KiB
14Accepted2/243ms11596 KiB
15Accepted2/245ms11656 KiB
16Accepted2/245ms11700 KiB
17Accepted2/250ms11720 KiB
18Accepted2/254ms11988 KiB
19Accepted2/279ms12344 KiB
20Accepted2/2163ms12564 KiB
21Accepted2/2167ms12776 KiB
22Accepted3/3187ms12984 KiB
23Time limit exceeded0/3284ms10888 KiB
24Time limit exceeded0/3293ms11284 KiB