76452024-01-10 10:31:45FulopMateRobotokcpp17Time limit exceeded 22/50500ms10280 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m, k; cin>>n>>m>>k;
	vector<vector<int>> v(n);
	for(int i = 0; i < k; i++){
		int a, b; cin>>a>>b; a--; b--;
		v[a].push_back(b);
	}
	for(auto&i:v)sort(i.begin(), i.end());
	int ans = 0;
	while(k){
		ans++;
		int x = 0;
		for(int i = 0; i < n; i++){
			bool b = false;
			int ujx = x;
			while(!v[i].empty() && v[i].back() >= x){
				if(!b){
					b = true;
					ujx = v[i].back();
				}
				v[i].pop_back();
				k--;
			}
			x = ujx;
		}
	}
	cout<<ans<<endl;
}
SubtaskSumTestVerdictTimeMemory
base22/50
1Accepted0/03ms1828 KiB
2Accepted0/0345ms10280 KiB
3Accepted2/23ms2308 KiB
4Accepted2/23ms2516 KiB
5Accepted2/23ms2728 KiB
6Accepted2/24ms3088 KiB
7Accepted2/23ms3048 KiB
8Accepted2/23ms3360 KiB
9Accepted2/23ms3276 KiB
10Accepted2/23ms3264 KiB
11Accepted2/27ms3588 KiB
12Accepted2/216ms3952 KiB
13Accepted2/24ms3664 KiB
14Time limit exceeded0/2500ms7308 KiB
15Time limit exceeded0/2474ms8440 KiB
16Time limit exceeded0/2451ms5632 KiB
17Time limit exceeded0/4462ms8492 KiB
18Time limit exceeded0/6467ms8796 KiB
19Time limit exceeded0/6467ms8764 KiB
20Time limit exceeded0/6474ms6940 KiB