June Cook-Off 2021 Division 3

 Home » Compete » June Cook-Off 2021 Division 3


Scorable Problems for Division 3

June Cook-Off 2021 Division 3


Chefland Visa Problem Code: VISA


Ash is trying to get visa to Chefland. For the visa to be approved, he needs to satisfy the following three criteria:

  • Solve at least x1 problems on Codechef.
  • Have at least y1 current rating on Codechef.
  • Make his last submission at most z1 months ago.

You are given the number of problems solved by Chef (x2), his current rating (y2) and the information that he made his last submission z2 months ago. Determine whether he will get the visa.

Input

  • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains six space-separated integers x1x2y1y2z1 and z2.

Output

For each test case, print a single line containing the string "YES" if Chef will get the visa or "NO" if he will not.

You may print each character of the string in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).

Constraints

  • 1T5,000
  • 20x1,x250
  • 1,900y1,y22,100
  • 1z1,z26

Example Input

4
20 50 2100 1900 6 6
50 20 1900 1900 5 5
20 20 1900 1900 1 6
27 27 1920 1920 3 3

Example Output

NO
NO
NO
YES

Explanation

Example case 1: Chef's rating is less than the minimum required rating.

Example case 2: Chef has solved a smaller number of problems than the minimum required number.

Example case 3: Chef's last submission was made before the allowed period.

Example case 4: All three conditions are met.


Python :

for _ in range(int(input())):
    x1, x2, y1, y2, z1, z2 = map(int, input().split())
    if(x2>=x1 and y2>=y1 and z2<=z1):
        print("YES")
    else:
        print("NO")


C++ :

#include <iostream>
using namespace std;

int main() {
  int t;
  cin>>t;
  for (int i = 0; i < t; i++) {
      int x1,x2,y1,y2,z1,z2;
      cin>>x1>>x2>>y1>>y2>>z1>>z2;
      if((x1<=x2)&&(y1<=y2)&&(z1>=z2)){
          cout<<"YES"<<endl;
      }
      else{
          cout<<"NO"<<endl;
      }
  }
  return 0;
}


ICPC Balloons Problem Code: BALLOON


Chef is participating in an ICPC regional contest, in which there is a total of N problems (numbered 1 through N) with varying difficulties. For each valid i, the i-th easiest problem is problem Ai.

After a team solves a problem, a balloon with a colour representing that problem is tied next to their desk. Chef is fond of colours in VIBGYOR, which are representative of the problems with numbers 1 through 7. The remaining problems have their own representative colours too.

Find the minimum number of problems which Chef's team needs to solve in order to get all the balloons for problems 1 through 7 (and possibly some other balloons too) tied next to their desk, if you know that Chef's team knows the difficulties of all problems and solves the problems in increasing order of difficulty.

Input

  • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first line of each test case contains a single integer N.
  • The second line contains N space-separated integers A1,A2,,AN.

Output

For each test case, print a single line containing one integer ― the minimum number of problems Chef's team needs to solve.

Constraints

  • 1T10,500
  • 7N15
  • 1AiN for each valid i
  • A1,A2,,AN are pairwise distinct

Example Input

3
7
1 2 3 4 5 7 6
8
8 7 6 5 4 3 2 1
9
7 4 3 5 6 1 8 2 9

Example Output

7
8
8

Explanation

Example case 1: Since there are a total of 7 problems, Chef's team will have to solve all of them.

Example case 2: Problems 1 through 7 appear among the first 8 problems.

Example case 3: Problems 1 through 7 again appear among the first 8 problems.


Python :

for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    count=0
    for i in range(n):
        if(l[i]<=7):
            count+=1
        if(count==7):
            break
    print(i+1)


C++ :



#include <bits/stdc++.h>
using namespace std;
#define FAST1 ios_base::sync_with_stdio(false)
#define ll long long int
#define FAST2 cin.tie(NULL)

int main() {
// your code goes here
FAST1;
FAST2;
int t;
cin>>t;
while(t--){
    ll n;
    cin>>n;
    ll a[n],count=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<=7) count=i;
    }
    cout<<count+1<<"\n";
}
return 0;
}




The Wave Problem Code: WAV2


Chef is stuck in the wavey world of polynomials. You are given all N roots of a polynomial P(x)=i=1N(xai). The roots are pairwise distinct integers, but they are not given in any particular order.

To help Chef escape, you should answer Q queries (numbered 1 through Q). For each valid i, in the i-th query, you are given an integer xi and you have to determine whether P(xi) is positive, negative or 0.

Input

  • The first line of the input contains two space-separated integers N and Q.
  • The second line contains N space-separated integers a1,a2,,aN.
  • Q lines follow. For each valid i, the i-th of these lines contains a single integer xi describing the i-th query.

Output

For each query, print a single line containing the string "POSITIVE""NEGATIVE" or "0" (without quotes) describing the value of the polynomial for the i-th query.

Constraints

  • 1N,Q2105
  • |ai|109 for each valid i
  • a1,a2,,aN are pairwise distinct
  • |xi|109 for each valid i

Example Input

4 6
1 3 5 100
-2
2
4
80
107
5

Example Output

POSITIVE
NEGATIVE
POSITIVE
NEGATIVE
POSITIVE
0

Python :

import bisect
N,Q=map(int,input().split())
arr=list(map(int,input().split()))
arr.sort()
for it in range(Q):
    e=int(input())
    if e>arr[-1]:
        print("POSITIVE")
        continue
    if e<arr[0]:
        if N%2==0:
            print("POSITIVE")
            continue
        else:
            print("NEGATIVE")
            continue
    ba=bisect.bisect_left(arr,e)
    if ba+1!=N:
        if e == arr[ba+1]:
            print(0)
            continue
    if e==arr[ba]:
        print(0)
        continue
    if (N-ba)%2==1:
        print("NEGATIVE")
        continue
    else:
        print("POSITIVE")
        continue

Cpp :


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST1 ios_base::sync_with_stdio(false);
#define FAST2 cin.tie(NULL);
 
 
void solve(){
    ll n,q;
    cin>>n>>q;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    for(ll i=0;i<q;i++){
        ll x;
        cin>>x;
        ll pos=lower_bound(arr,arr+n,x)-arr;
        if(pos<n && arr[pos]==x)
            cout<<0<<endl;
        else if(pos%2==0)
            cout<<"POSITIVE"<<endl;
        else
            cout<<"NEGATIVE"<<endl;
 
    }
}
 
int main(){
    FAST1;
    FAST2;
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}