ONE KINGDOME!!
N one dimensional kingdoms are represented as intervals of the form [ai , bi] on the real line.
A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L
≤ x ≤ R.
A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L
≤ x ≤ R.
Your task is to determine minimum number of bombs required to destroy all the one dimensional kingdoms.
OR
THERE ARE MANY HORIZONTAL LINES PARALALL TO X AXIX . FIND MINIMUM NO OF VERTICAL LINE NEEDED TO CUT ALL LINES ....
#########################################EDITORIAL######################################
###########################################CODE###########################################
- #include<iostream>
- using namespace std;
- #include<algorithm>
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- long long int m,n;
- cin>>n>>m;
- long long int arr[m];
- for(int i=0;i<m;i++)
- cin>>arr[i];
- sort(arr,arr+m);
- int sum=0,f=0;
- for(int i=0;i<m;i++)
- {
- sum+=arr[i];
- if(arr[i]*(arr[i]+1)/2-sum<arr[i])
- {
- if(arr[i]%2==1) cout<<"Chef\n";
- else
- cout<<"Mom\n";
- // cout<<arr[i]<<endl;
- f=1;
- break;
- }
- }
- if(f==0)
- {
- if((n*(n+1)/2-sum)%2==0) cout<<"Chef\n";
- else
- cout<<"Mom\n";
- }
- }
- return 0;
- }
No comments:
Post a Comment