229912026-01-16 10:25:24linhnk20G (40 pont)cpp14Wrong answer 31/4045ms1004 KiB
#include <bits/stdc++.h>
using namespace std;
using pii =pair<int, int>;
int main() {
	int n, q, d=0;
	cin>>n>>q;
	vector<int> haz(n);
	vector<pii> tv(q);
	vector<int> ki(q);
	for(int i=0; i<n; i++){
		cin>>haz[i];
	}
	for(int i=0; i<q; i++){
		cin>>tv[i].first;
		tv[i].second=i;
	}
	sort(tv.begin(), tv.end());
	int a=0, b=0;
	for(int i=0; i<q; i++){
		if(tv[i].first>haz[0])
		break;
		ki[tv[i].second]=0;
		b=i;
	}
	d=1;
	for(int i=b; i<q; i++){
		while(a<n&&tv[i].first>=haz[a]){
			d++; a++;
		}
		ki[tv[i].second]=d;
	}
	for(auto x:ki)
	cout<<x<<"\n";
}
SubtaskSumTestVerdictTimeMemory
base31/40
1Accepted0/01ms316 KiB
2Wrong answer0/035ms1004 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/22ms316 KiB
7Wrong answer0/33ms316 KiB
8Accepted3/345ms920 KiB
9Accepted3/343ms912 KiB
10Accepted3/345ms916 KiB
11Accepted4/443ms920 KiB
12Accepted4/443ms1004 KiB
13Accepted4/445ms916 KiB
14Accepted4/445ms1004 KiB
15Accepted4/445ms920 KiB