[Zhengqing] [1801] Sister Xue's Little Animals

Problem Description

Loading...

Problem Analysis

Sort with sort
then compare each pair
of hunger value and energy value in order

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<stdio.h>
#include<algorithm>
using namespace std;
int main() {
	int T,n;
	int i;
	int a[120],b[120];
	scanf("%d",&T);
	while(T--) {
		scanf("%d",&n);
		for(i=0; i<n; i++)
			scanf("%d",&a[i]);
		for(i=0; i<n; i++)
			scanf("%d",&b[i]);
		sort(a,a+n);
		sort(b,b+n);
		for(i=0; i<n; i++) {
			if(a[i]>b[i])
				break;
		}
		if(i<n)
			printf("NO\n");
		else
			printf("YES\n");

	}
	return 0;
}

Problem link: 【ZZULI】[1801]xue’s Little Animals

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...