Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Task 1
- /* TAHMID RAHMAN
- DAMIAN FOREVER
- MATH LOVER
- NEVER GIVE UP
- */
- #include<bits/stdc++.h>
- using namespace std;
- #define pi acos(-1.0)
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define ll long long
- #define pb push_back
- #define fi first
- #define se second
- #define in insert
- #define mp make_pair
- #define GCD(a,b) __gcd(a,b);
- #define endl "\n"
- #define FRU freopen("out.txt","w",stdout)
- #define FRO freopen("in.txt","r",stdin)
- #define INFLL 9223372036854775807
- #define debug 0
- #define MAXN 100001
- #define ar array
- const int mxN=2e5;
- const int MOD=1e9+7;
- bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
- #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
- #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
- //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
- int main()
- {
- fastio;
- ll n,i,x,j;
- cin>>n;
- vector<ll>v(n);
- bool ok=true;
- ll prev=0;
- for(i=0;i<n;i++)
- {
- cin>>x;
- v[i]=x;
- if(prev>x)
- {
- ok=false;
- }
- prev=x;
- }
- if(ok)
- {
- cout<<"Yes"<<endl;
- return 0;
- }
- cout<<"NO"<<endl;
- //debugx(v);
- for(i=0;i<n-1;i++)
- {
- for(j=0;j<n-i-1;j++)
- {
- if(v[j]>v[j+1])
- swap(v[j],v[j+1]);
- }
- //debugx(v);
- }
- for(auto x:v)
- {
- cout<<x<<" ";
- }
- cout<<endl;
- }
- //Task 2
- /* TAHMID RAHMAN
- DAMIAN FOREVER
- MATH LOVER
- NEVER GIVE UP
- */
- #include<bits/stdc++.h>
- using namespace std;
- #define pi acos(-1.0)
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define ll long long
- #define pb push_back
- #define fi first
- #define se second
- #define in insert
- #define mp make_pair
- #define GCD(a,b) __gcd(a,b);
- #define endl "\n"
- #define FRU freopen("out.txt","w",stdout)
- #define FRO freopen("in.txt","r",stdin)
- #define INFLL 9223372036854775807
- #define debug 0
- #define MAXN 100001
- #define ar array
- const int mxN=2e5;
- const int MOD=1e9+7;
- bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
- #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
- #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
- //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
- int main()
- {
- fastio;
- ll t;
- cin>>t;
- while(t--)
- {
- ll n,i,j,m;
- cin>>n>>m;
- vector<ll>v(n);
- for(i=0;i<n;i++)
- {
- cin>>v[i];
- }
- ll x=(n-m);
- for(i=0;i<n-1;i++)
- {
- for(j=0;j<n-1-i;j++)
- {
- if(v[j]>v[j+1])
- {
- swap(v[j],v[j+1]);
- }
- }
- }
- //debugx(v);
- vector<ll>priffix_sum;
- priffix_sum.pb(0);
- ll sum=0;
- for(i=1;i<=n;i++)
- {
- sum+=v[i-1];
- priffix_sum.pb(sum);
- }
- // debugx(priffix_sum);
- ll max_sum=priffix_sum[n]-priffix_sum[n-x];
- ll min_sum=priffix_sum[x];
- //cout<<max_sum<<" "<<min_sum<<endl;
- cout<<max_sum-min_sum<<endl;
- }
- }
- //Task 3
- /* TAHMID RAHMAN
- DAMIAN FOREVER
- MATH LOVER
- NEVER GIVE UP
- */
- #include<bits/stdc++.h>
- using namespace std;
- #define pi acos(-1.0)
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define ll long long
- #define pb push_back
- #define fi first
- #define se second
- #define in insert
- #define mp make_pair
- #define GCD(a,b) __gcd(a,b);
- #define endl "\n"
- #define FRU freopen("out.txt","w",stdout)
- #define FRO freopen("in.txt","r",stdin)
- #define INFLL 9223372036854775807
- #define debug 0
- #define MAXN 100001
- #define ar array
- const int mxN=2e5;
- const int MOD=1e9+7;
- bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
- {
- return (a.second < b.second);
- }
- #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
- #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
- //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
- int main()
- {
- fastio;
- ll t;
- t=1;
- //cin>>t;
- while(t--)
- {
- ll n,i;
- cin>>n;
- vector<ll>v(n);
- ll max_num=-1;
- for(i=0;i<n;i++)
- {
- cin>>v[i];
- max_num=max(max_num,v[i]);
- }
- ll a[max_num+1]={0};
- for(i=0;i<n;i++)
- {
- a[v[i]]=i;
- }
- for(i=0;i<n-1;i++)
- {
- for(ll j=0;j<n-1-i;j++)
- {
- if(v[j]>v[j+1])
- swap(v[j],v[j+1]);
- }
- }
- for(i=0;i<n;i++)
- {
- cout<<a[v[i]]<<" ";
- }
- cout<<endl;
- }
- }
- //Task 4
- /* TAHMID RAHMAN
- DAMIAN FOREVER
- MATH LOVER
- NEVER GIVE UP
- */
- #include<bits/stdc++.h>
- using namespace std;
- #define pi acos(-1.0)
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define ll long long
- #define pb push_back
- #define fi first
- #define se second
- #define in insert
- #define mp make_pair
- #define GCD(a,b) __gcd(a,b);
- #define endl "\n"
- #define FRU freopen("out.txt","w",stdout)
- #define FRO freopen("in.txt","r",stdin)
- #define INFLL 9223372036854775807
- #define debug 0
- #define MAXN 100001
- #define ar array
- const int mxN=2e5;
- const int MOD=1e9+7;
- bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
- #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
- #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
- //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
- int main()
- {
- fastio;
- ll n,k,i,x;
- cin>>n>>k;
- ll c=0;
- for(i=0;i<n;i++)
- {
- cin>>x;
- if((5-x)>=k)
- {
- c++;
- }
- }
- cout<<(c/3)<<endl;
- }
- //Task 5
- /* TAHMID RAHMAN
- DAMIAN FOREVER
- MATH LOVER
- NEVER GIVE UP
- */
- #include<bits/stdc++.h>
- using namespace std;
- #define pi acos(-1.0)
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define ll long long
- #define pb push_back
- #define fi first
- #define se second
- #define in insert
- #define mp make_pair
- #define GCD(a,b) __gcd(a,b);
- #define endl "\n"
- #define FRU freopen("out.txt","w",stdout)
- #define FRO freopen("in.txt","r",stdin)
- #define INFLL 9223372036854775807
- #define debug 0
- #define MAXN 100001
- #define ar array
- const int mxN=2e5;
- const int MOD=1e9+7;
- bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
- #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
- #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
- //Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
- struct stu
- {
- string name;
- ll data_structure;
- ll networking;
- ll machine_learning;
- ll total_marks;
- };
- bool comp(stu x , stu y)
- {
- if(x.total_marks!=y.total_marks)
- return x.total_marks>y.total_marks;
- if(x.machine_learning!=y.machine_learning)
- return x.machine_learning>y.machine_learning;
- return x.data_structure>y.data_structure;
- }
- int main()
- {
- ll n,i;
- cin>>n;
- stu a[n];
- for(i=0;i<n;i++)
- {
- cin>>a[i].name;
- cin>>a[i].machine_learning;
- cin>>a[i].data_structure;
- cin>>a[i].networking;
- a[i].total_marks=a[i].data_structure+a[i].networking+a[i].machine_learning;
- }
- sort(a,a+n,comp);
- for(i=0;i<n;i++)
- {
- cout<<i+1<<" "<<a[i].name<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement