64522023-11-30 17:24:56KorinaKártyajátékcpp11Runtime error 13/3043ms64864 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	int t[n];
	for (int i=0; i<k; i++){
		cin >> t[i];
	}
	vector<pair<int, int>>asztal;
	asztal.push_back(make_pair(t[0], 0));
	int l, r, mid;
	for (int i=1; i<k; i++){
		if (asztal[asztal.size()-1].first < t[i]){
			asztal.push_back(make_pair(t[i], 0));
		}
		else{
			l = 0;
			r = asztal.size();
			while(r-l > 1){
				mid = (l+r)/2;
				if (asztal[mid].first < t[i]){
					l = mid;
				}
				else{
					r = mid;
				}
			}
			asztal[r].second ++;
		}
	}
	int ans = 0;
	for (auto i:asztal){
		if (i.second > 0) ans ++;
	}
	cout << ans;

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base13/30
1Accepted0/03ms1968 KiB
2Runtime error0/023ms64864 KiB
3Accepted1/13ms3780 KiB
4Accepted1/13ms4012 KiB
5Accepted1/13ms4224 KiB
6Wrong answer0/24ms4436 KiB
7Accepted2/24ms4660 KiB
8Wrong answer0/24ms4868 KiB
9Wrong answer0/128ms4988 KiB
10Accepted2/241ms5968 KiB
11Accepted3/341ms6096 KiB
12Accepted3/343ms6168 KiB
13Runtime error0/121ms63388 KiB
14Runtime error0/225ms63276 KiB
15Runtime error0/325ms63268 KiB
16Runtime error0/324ms63256 KiB
17Runtime error0/325ms63240 KiB