View Code of Problem 5

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int x,y;
	while(n--){
		int i;
		int a[1000][1000] = { },flag = 0;
		cin>>x>>y;
	for(int i = 0;i<x;i++)cin>>a[i][0]>>a[i][1];
		
	for(i = 0;i<y;i++){
		for(int i = 0;i<x;i++){
			if(a[i][0] > a[i+1][0]) flag = i;
			else if( a[i][0] == a[i+1][0] && a[i][1] > a[i+1][1]) flag = i;
		}
	}
	if(i!=y-1) cout<<(flag+1)<<" ";
	else cout<<(flag+1);
		
		
		
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 5