Submission #60323453


Source Code Expand

#include <bits/stdc++.h>
#include <vector>

using namespace std;

/*

add the index to the value when making the sushis list
sort the sushis list, so you know its always going to be

*/

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> gourmets;
	vector<int> result(m);
	vector<pair<int, int>> delic;
	int minG = INT_MAX;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		gourmets.push_back(x);
		if (x < minG) {
			minG = x;
		}
	}
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		delic.push_back({x, i});
	}

	std::sort(delic.begin(), delic.end(),
			  [](auto& left, auto& right) { return left.first > right.first; });
	// for (auto& deli : delic) {
	// 	cout << "sushi: " << deli.first << endl;
	// }
	for (int i = 0, j = 0; i < m; i++) {
		int sushi = delic[i].first;
		if (sushi < minG) {
			result[delic[i].second] = -1;
			continue;
		}
		// cerr << "delic[i].first: " << delic[i].first << endl;
		// cerr << "gourmets[j]: " << gourmets[j] << endl;
		while (j < n && delic[i].first < gourmets[j])
			j++;
		// cerr << "j: " << j << endl;

		result[delic[i].second] = j + 1;
	}
	for (auto& res : result) {
		cout << res << endl;
	}
}

int main() {
	int t = 1;
	while (t--)
		solve();
	return 0;
}

Submission Info

Submission Time
Task C - Kaiten Sushi
User utenret
Language C++ 20 (gcc 12.2)
Score 350
Code Size 1280 Byte
Status AC
Exec Time 271 ms
Memory 6928 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3532 KiB
00_sample_01.txt AC 1 ms 3648 KiB
00_sample_02.txt AC 1 ms 3532 KiB
01_random_00.txt AC 111 ms 4740 KiB
01_random_01.txt AC 48 ms 4004 KiB
01_random_02.txt AC 209 ms 6192 KiB
01_random_03.txt AC 217 ms 6492 KiB
01_random_04.txt AC 124 ms 4900 KiB
02_random2_00.txt AC 264 ms 6928 KiB
02_random2_01.txt AC 271 ms 6768 KiB
02_random2_02.txt AC 268 ms 6864 KiB
02_random2_03.txt AC 269 ms 6868 KiB
02_random2_04.txt AC 269 ms 6824 KiB
02_random2_05.txt AC 268 ms 6716 KiB
02_random2_06.txt AC 268 ms 6788 KiB
02_random2_07.txt AC 269 ms 6812 KiB
02_random2_08.txt AC 268 ms 6724 KiB
02_random2_09.txt AC 268 ms 6760 KiB
02_random2_10.txt AC 268 ms 6788 KiB
02_random2_11.txt AC 268 ms 6772 KiB
02_random2_12.txt AC 268 ms 6736 KiB
02_random2_13.txt AC 268 ms 6724 KiB
02_random2_14.txt AC 267 ms 6824 KiB
02_random2_15.txt AC 267 ms 6772 KiB
02_random2_16.txt AC 268 ms 6824 KiB
03_handmade_00.txt AC 252 ms 6724 KiB
03_handmade_01.txt AC 249 ms 6776 KiB
03_handmade_02.txt AC 219 ms 5912 KiB
03_handmade_03.txt AC 220 ms 5944 KiB
03_handmade_04.txt AC 1 ms 3464 KiB