ZCMU-1304: Pushing Snowman (Water)

There is one thing to say, this question can actually be directly violent, but the format is wrong. WA is 5 shots... ashamed and ashamed

topic

ZCMU-1304
1304: Push the snowman

Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 1211 Solved: 373
[Submit][Status][Web Board]
Description

Winter is here and it starts to snow. Song Shen and his second brother decided to go out and push the snowman. Everyone knows that a snowman is composed of two snowballs. Songshen and the second brother decided to divide the work and cooperate, each of them rolled a few snowballs, and then combined them together. One hour later, Songshen rolled a total of n snowballs. The radius of each snowball was a1, a2, a3...,an. At the same time, the second brother rolled a total of m snowballs, with the radius of each snowball. They are b1, b2, b3,..., bn. They decided to each choose a snowball and push it into a snowman. For aesthetic reasons, suppose the radii of the two snowballs are r1 and r2 respectively (r1<=r2). They think that when the radii of the snowman’s two snowballs satisfy 3/2 r1<=r2<=2 r1, then This snowman is beautiful. Can you tell them whether they can form a beautiful snowman?

Input

Multiple sets of test data.
The first line of each set of test data is two positive integers n, m (1<=n, m<=100).
In the second line, n positive integers separated by spaces represent the radius of Songshen's snowball.
In the third line, m positive integers separated by spaces represent the radius of the snowball for the second brother.
The radius of all snowballs is not greater than 100.

Output

For each set of test data, if Songshen and the second brother can form a beautiful snowman, output "Yes", otherwise output "No".

Sample Input

2 1
2 3
2
1 2
4
9 10

Sample Output

Yes
No

thought

This question has no thoughts at all (otherwise it is a super water question), just direct violence...

AC code

#include<bits/stdc++.h>
using namespace std;
int main(){
    
    
      
    int n,m;
    int a[110],b[110];
    while(~scanf("%d%d",&n,&m))
    {
    
    
        for(int i=0;i<n;i++)scanf("%d",&a[i]);
        for(int i=0;i<m;i++)scanf("%d",&b[i]);
        bool f = false;
        for(int i=0;i<n;i++){
    
    
            for(int j=0;j<m;j++)
            {
    
    
                if(3/2*a[i]<=b[j]&&b[j]<=2*a[i])f = true;
                if(3/2*b[j]<=a[i]&&a[i]<=2*b[j])f = true;
                if(f)break;
            }
            if(f)break;
        }
        if(f)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
      return 0;
      }


to sum up

Water, there is nothing to sum up, just don't think about the complexity, the data volume is only 1e4, it can't be blown up (write magic for ICPC, it depends on the time complexity of everything...but it is also a good habit)

Guess you like

Origin blog.csdn.net/DAVID3A/article/details/114947254