diff --git a/Codechef/Codeshef-January-2021-solutions/ANTSCHEF.cpp b/Codechef/Codeshef-January-2021-solutions/ANTSCHEF.cpp new file mode 100644 index 0000000..7300b6f --- /dev/null +++ b/Codechef/Codeshef-January-2021-solutions/ANTSCHEF.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int t; + cin>>t; + while (t--) + { + int n; + cin>>n; + int m; + cin>>m; + long long int a[m]; + for (int i=0;i>a[i]; + } + long long int cntneg=0, cntpos=0, sum=0; + if(n==1) + { + sort(a,a+m); + if(a[0]>0)cout<<0<0){cntneg=i;cntpos=m-i;break;} + } + while (cntneg>0 && cntpos>0) + { + sum = sum + cntneg+cntpos -1; + cntneg --; + cntpos --; + } + cout< + +using namespace std; + +#define ll long long + + + +int main() { + ios_base::sync_with_stdio(0); + cin.tie(0); cout.tie(0); + + int t; + cin>>t; + while(t--){ + int n,k,x,y; + + cin>>n>>k>>x>>y; + mapm; + m.insert(pair(x, y)); + + if(x==y){ + cout<>vect; + if(x + +using namespace std; + +#define ll long long + + +ll convert(string s) { + ll n=stoi(s); + + ll dec = 0, i = 0, rem; + while (n != 0) { + rem = n % 10; + n /= 10; + dec += rem * pow(2, i); + ++i; + } + return dec; +} + + + +int main() { + ios_base::sync_with_stdio(0); + cin.tie(0); cout.tie(0); + char a [16] ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'}; + ll t,n,num; + string s,s1; + // char a [16] ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'}; + cin>>t; + while(t--){ + cin>>n; + cin>>s; + for(int i=0;i + +using namespace std; + +#define ll long long + + + +int main() { + ios_base::sync_with_stdio(0); + cin.tie(0); cout.tie(0); + + int t,n,k,d,p,sum; + cin>>t; + while(t--){ + cin>>n>>k>>d; + sum=0; + + + for(int i=0;i>p; + sum+=p; + } + + if(sum + +using namespace std; + +#define ll int + + + + +int main() { + ios_base::sync_with_stdio(0); + cin.tie(0); cout.tie(0); + + int t; + cin >>t; + while(t--){ + int size1; + int size2; + cin>>size1>>size2; + int* arr1=new int[size1]; + int* arr2=new int[size2]; + int sum1=0,sum2=0; + for(int i=0;i>arr1[i]; + sum1+=arr1[i]; + } + for(int i=0;i>arr2[i]; + sum2+=arr2[i]; + } + if(sum1>sum2){ + cout<<"0"<sum2 || j<0){ + break; + } + } + if(sum1>sum2){ + cout< +#define ll long long int + +using namespace std; + +ll result(ll x,ll a[],ll n){ + int pos[x+1]={'\0'}; + pos[0]=1; + for(int i=0;i=a[i];j--){ + if(pos[j-a[i]]==1) + pos[j]=1; + } + return pos[x]; +} + +void solve(){ + ll n,k; + cin>>n>>k; + ll sum=0,ans=0; + ll a[n]={'\0'}; + + for(ll i=0;i>a[i]; + sum+=a[i]; + } + + sort(a,a+n,greater<>()); + + if(n==1 || sum<2*k){ + cout<<"-1\n"; + return; + } + + else if(sum==2*k){ + + if(sum%2==1 || a[0]>k){ + cout<<"-1\n"; + return; + } + else if(a[0]==k){ + cout<=k){ + ans =1; + ll tempsum=0; + for(ll i=1;i=k){ + cout<=2*k){ + cout<>t; + while(t--){ + solve(); + } +} \ No newline at end of file