u
This commit is contained in:
parent
26f0cfcd06
commit
ee14bb7e13
73
Codes/1923 A - Moving Chips/1923A.cpp
Normal file
73
Codes/1923 A - Moving Chips/1923A.cpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include<bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
#define ll long long
|
||||||
|
#define ull unsigned long long
|
||||||
|
#define endl '\n'
|
||||||
|
#define ff first
|
||||||
|
#define ss second
|
||||||
|
#define pb push_back
|
||||||
|
#define all(x) x.begin(), x.end()
|
||||||
|
#define sz(x) (int)(x).size()
|
||||||
|
#define yes cout<<"YES"<<endl
|
||||||
|
#define no cout<<"NO"<<endl
|
||||||
|
#define neg1 cout<<-1<<endl
|
||||||
|
#define PI 3.141592653589793238
|
||||||
|
#define MIN INT_MIN
|
||||||
|
#define MAX INT_MAX
|
||||||
|
#define INF LONG_LONG_MAX
|
||||||
|
#define MOD 1000000007
|
||||||
|
#define LLM 1000000000000000007
|
||||||
|
|
||||||
|
ll factorial(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||||
|
ll nPr(ll n, ll r) { return factorial(n) / factorial(n - r); }
|
||||||
|
ll nCr(ll n, ll r) { return factorial(n) / (factorial(r) * factorial(n - r));}
|
||||||
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
|
ull mypow(ull a, ull b) { ull ans = 1; a%=MOD; while(b){ if (b&1) ans = (ans*a) % MOD; a = (a*a) % MOD; b >>= 1; } return ans; }
|
||||||
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i*i <= n; i++) if(n % i == 0) return false; return true; }
|
||||||
|
|
||||||
|
#ifndef ONLINE_JUDGE
|
||||||
|
#define dbg(x...) cerr << #x << " : "; _print(x)
|
||||||
|
#else
|
||||||
|
#define debug(...)
|
||||||
|
#endif
|
||||||
|
void __print(int x) {cerr << x;}void __print(long x) {cerr << x;} void __print(long long x){cerr << x;}
|
||||||
|
void __print(unsigned x){cerr << x;} void __print(unsigned long x){cerr << x;} void __print(unsigned long long x){cerr << x;}
|
||||||
|
void __print(float x){cerr << x;} void __print(double x){cerr << x;} void __print(long double x){cerr << x;}
|
||||||
|
void __print(char x){cerr << x;} void __print(const char *x){cerr << x;} void __print(const string &x){cerr << x;}
|
||||||
|
void __print(bool x){cerr << (x ? "true" : "false");} void _print() { cerr << "\n"; }
|
||||||
|
template <typename A> void __print(const A &x); template <typename A, typename B> void __print(const pair<A, B> &p);
|
||||||
|
template <typename A> void __print(const A &x) {bool f=1; cerr << '['; for (const auto &i : x) {cerr << (f ? "" : ","), __print(i); f = 0;} cerr << ']';}
|
||||||
|
template <typename A, typename B> void __print(const pair<A, B> &p) {cerr << '('; __print(p.first); cerr << ','; __print(p.second); cerr << ')';}
|
||||||
|
template <typename Head, typename... Tail> void _print(const Head &H, const Tail &...T) { __print(H); if (sizeof...(T)) cerr << ", "; _print(T...);}
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void solve()
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
cin>>n;
|
||||||
|
vector<int>v(n);
|
||||||
|
for(auto &i:v) cin>>i;
|
||||||
|
while(v.back()==0)
|
||||||
|
v.pop_back();
|
||||||
|
int ct=0,ok=0;
|
||||||
|
for(int i=0; i<sz(v); ++i)
|
||||||
|
{
|
||||||
|
if(v[i]==0 && ok)
|
||||||
|
ct++;
|
||||||
|
if(v[i]==1)
|
||||||
|
ok=1;
|
||||||
|
}
|
||||||
|
cout<<ct<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
FAST_IO;
|
||||||
|
int TC = 1;
|
||||||
|
cin >> TC;
|
||||||
|
while (TC--)
|
||||||
|
solve();
|
||||||
|
}
|
70
Codes/1930 A - Maximise The Score/1930A.cpp
Normal file
70
Codes/1930 A - Maximise The Score/1930A.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include<bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
#define ll long long
|
||||||
|
#define ull unsigned long long
|
||||||
|
#define endl '\n'
|
||||||
|
#define ff first
|
||||||
|
#define ss second
|
||||||
|
#define pb push_back
|
||||||
|
#define all(x) x.begin(), x.end()
|
||||||
|
#define sz(x) (int)(x).size()
|
||||||
|
#define yes cout<<"YES"<<endl
|
||||||
|
#define no cout<<"NO"<<endl
|
||||||
|
#define neg1 cout<<-1<<endl
|
||||||
|
#define PI 3.141592653589793238
|
||||||
|
#define MIN INT_MIN
|
||||||
|
#define MAX INT_MAX
|
||||||
|
#define INF LONG_LONG_MAX
|
||||||
|
#define MOD 1000000007
|
||||||
|
#define LLM 1000000000000000007
|
||||||
|
|
||||||
|
ll factorial(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||||
|
ll nPr(ll n, ll r) { return factorial(n) / factorial(n - r); }
|
||||||
|
ll nCr(ll n, ll r) { return factorial(n) / (factorial(r) * factorial(n - r));}
|
||||||
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
|
ull mypow(ull a, ull b) { ull ans = 1; a%=MOD; while(b){ if (b&1) ans = (ans*a) % MOD; a = (a*a) % MOD; b >>= 1; } return ans; }
|
||||||
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i*i <= n; i++) if(n % i == 0) return false; return true; }
|
||||||
|
|
||||||
|
#ifndef ONLINE_JUDGE
|
||||||
|
#define dbg(x...) cerr << #x << " : "; _print(x)
|
||||||
|
#else
|
||||||
|
#define debug(...)
|
||||||
|
#endif
|
||||||
|
void __print(int x) {cerr << x;}void __print(long x) {cerr << x;} void __print(long long x){cerr << x;}
|
||||||
|
void __print(unsigned x){cerr << x;} void __print(unsigned long x){cerr << x;} void __print(unsigned long long x){cerr << x;}
|
||||||
|
void __print(float x){cerr << x;} void __print(double x){cerr << x;} void __print(long double x){cerr << x;}
|
||||||
|
void __print(char x){cerr << x;} void __print(const char *x){cerr << x;} void __print(const string &x){cerr << x;}
|
||||||
|
void __print(bool x){cerr << (x ? "true" : "false");} void _print() { cerr << "\n"; }
|
||||||
|
template <typename A> void __print(const A &x); template <typename A, typename B> void __print(const pair<A, B> &p);
|
||||||
|
template <typename A> void __print(const A &x) {bool f=1; cerr << '['; for (const auto &i : x) {cerr << (f ? "" : ","), __print(i); f = 0;} cerr << ']';}
|
||||||
|
template <typename A, typename B> void __print(const pair<A, B> &p) {cerr << '('; __print(p.first); cerr << ','; __print(p.second); cerr << ')';}
|
||||||
|
template <typename Head, typename... Tail> void _print(const Head &H, const Tail &...T) { __print(H); if (sizeof...(T)) cerr << ", "; _print(T...);}
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void solve()
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
cin>>n;
|
||||||
|
n=2*n;
|
||||||
|
vector<int>v(n);
|
||||||
|
for(auto &i:v) cin>>i;
|
||||||
|
int ans=0;
|
||||||
|
sort(all(v));
|
||||||
|
for(int i=1; i<n; i+=2)
|
||||||
|
{
|
||||||
|
ans += min(v[i],v[i-1]);
|
||||||
|
}
|
||||||
|
cout<<ans<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
FAST_IO;
|
||||||
|
int TC = 1;
|
||||||
|
cin >> TC;
|
||||||
|
while (TC--)
|
||||||
|
solve();
|
||||||
|
}
|
72
Codes/1930 B - Permutation Printing/1930B.cpp
Normal file
72
Codes/1930 B - Permutation Printing/1930B.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include<bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||||
|
#define ll long long
|
||||||
|
#define ull unsigned long long
|
||||||
|
#define endl '\n'
|
||||||
|
#define ff first
|
||||||
|
#define ss second
|
||||||
|
#define pb push_back
|
||||||
|
#define all(x) x.begin(), x.end()
|
||||||
|
#define sz(x) (int)(x).size()
|
||||||
|
#define yes cout<<"YES"<<endl
|
||||||
|
#define no cout<<"NO"<<endl
|
||||||
|
#define neg1 cout<<-1<<endl
|
||||||
|
#define PI 3.141592653589793238
|
||||||
|
#define MIN INT_MIN
|
||||||
|
#define MAX INT_MAX
|
||||||
|
#define INF LONG_LONG_MAX
|
||||||
|
#define MOD 1000000007
|
||||||
|
#define LLM 1000000000000000007
|
||||||
|
|
||||||
|
ll factorial(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||||
|
ll nPr(ll n, ll r) { return factorial(n) / factorial(n - r); }
|
||||||
|
ll nCr(ll n, ll r) { return factorial(n) / (factorial(r) * factorial(n - r));}
|
||||||
|
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||||
|
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||||
|
ull mypow(ull a, ull b) { ull ans = 1; a%=MOD; while(b){ if (b&1) ans = (ans*a) % MOD; a = (a*a) % MOD; b >>= 1; } return ans; }
|
||||||
|
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i*i <= n; i++) if(n % i == 0) return false; return true; }
|
||||||
|
|
||||||
|
#ifndef ONLINE_JUDGE
|
||||||
|
#define dbg(x...) cerr << #x << " : "; _print(x)
|
||||||
|
#else
|
||||||
|
#define debug(...)
|
||||||
|
#endif
|
||||||
|
void __print(int x) {cerr << x;}void __print(long x) {cerr << x;} void __print(long long x){cerr << x;}
|
||||||
|
void __print(unsigned x){cerr << x;} void __print(unsigned long x){cerr << x;} void __print(unsigned long long x){cerr << x;}
|
||||||
|
void __print(float x){cerr << x;} void __print(double x){cerr << x;} void __print(long double x){cerr << x;}
|
||||||
|
void __print(char x){cerr << x;} void __print(const char *x){cerr << x;} void __print(const string &x){cerr << x;}
|
||||||
|
void __print(bool x){cerr << (x ? "true" : "false");} void _print() { cerr << "\n"; }
|
||||||
|
template <typename A> void __print(const A &x); template <typename A, typename B> void __print(const pair<A, B> &p);
|
||||||
|
template <typename A> void __print(const A &x) {bool f=1; cerr << '['; for (const auto &i : x) {cerr << (f ? "" : ","), __print(i); f = 0;} cerr << ']';}
|
||||||
|
template <typename A, typename B> void __print(const pair<A, B> &p) {cerr << '('; __print(p.first); cerr << ','; __print(p.second); cerr << ')';}
|
||||||
|
template <typename Head, typename... Tail> void _print(const Head &H, const Tail &...T) { __print(H); if (sizeof...(T)) cerr << ", "; _print(T...);}
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void solve()
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
cin>>n;
|
||||||
|
vector<int>v;
|
||||||
|
int s=1,e=n;
|
||||||
|
for(int i=1; i<=n; ++i)
|
||||||
|
{
|
||||||
|
if(i&1)
|
||||||
|
v.pb(s++);
|
||||||
|
else
|
||||||
|
v.pb(e--);
|
||||||
|
}
|
||||||
|
for(auto x:v)
|
||||||
|
cout<<x<<" ";
|
||||||
|
cout<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
FAST_IO;
|
||||||
|
int TC = 1;
|
||||||
|
cin >> TC;
|
||||||
|
while (TC--)
|
||||||
|
solve();
|
||||||
|
}
|
27
Readme.md
27
Readme.md
@ -270,18 +270,21 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
|
|||||||
| 258 | 1921 B | Arranging Cats | [Question](https://codeforces.com/problemset/problem/1921/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1921%20B%20-%20Arranging%20Cats)
|
| 258 | 1921 B | Arranging Cats | [Question](https://codeforces.com/problemset/problem/1921/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1921%20B%20-%20Arranging%20Cats)
|
||||||
| 259 | 1921 C | Sending Messages | [Question](https://codeforces.com/problemset/problem/1921/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1921%20C%20-%20Sending%20Messages)
|
| 259 | 1921 C | Sending Messages | [Question](https://codeforces.com/problemset/problem/1921/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1921%20C%20-%20Sending%20Messages)
|
||||||
| 260 | 1921 D | Very Different Array | [Question](https://codeforces.com/problemset/problem/1921/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1921%20D%20-%20Very%20Different%20Array)
|
| 260 | 1921 D | Very Different Array | [Question](https://codeforces.com/problemset/problem/1921/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1921%20D%20-%20Very%20Different%20Array)
|
||||||
| 261 | 1927 A | Make it White | [Question](https://codeforces.com/problemset/problem/1927/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20A%20-%20Make%20it%20White)
|
| 261 | 1923 A | Moving Chips | [Question](https://codeforces.com/problemset/problem/1923/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1923%20A%20-%20Moving%20Chips)
|
||||||
| 262 | 1927 B | Following the String | [Question](https://codeforces.com/problemset/problem/1927/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20B%20-%20Following%20the%20String)
|
| 262 | 1927 A | Make it White | [Question](https://codeforces.com/problemset/problem/1927/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20A%20-%20Make%20it%20White)
|
||||||
| 263 | 1927 C | Choose the Different Ones | [Question](https://codeforces.com/problemset/problem/1927/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20C%20-%20Choose%20the%20Different%20Ones)
|
| 263 | 1927 B | Following the String | [Question](https://codeforces.com/problemset/problem/1927/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20B%20-%20Following%20the%20String)
|
||||||
| 264 | 1927 D | Find the Different Ones! | [Question](https://codeforces.com/problemset/problem/1927/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20D%20-%20Find%20the%20Different%20Ones!)
|
| 264 | 1927 C | Choose the Different Ones | [Question](https://codeforces.com/problemset/problem/1927/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20C%20-%20Choose%20the%20Different%20Ones)
|
||||||
| 265 | 1927 E | Klever Permutation | [Question](https://codeforces.com/problemset/problem/1927/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20E%20-%20Klever%20Permutation)
|
| 265 | 1927 D | Find the Different Ones! | [Question](https://codeforces.com/problemset/problem/1927/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20D%20-%20Find%20the%20Different%20Ones!)
|
||||||
| 266 | 1928 A | Rectangle Cutting | [Question](https://codeforces.com/problemset/problem/1928/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1928%20A%20-%20Rectangle%20Cutting)
|
| 266 | 1927 E | Klever Permutation | [Question](https://codeforces.com/problemset/problem/1927/E) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1927%20E%20-%20Klever%20Permutation)
|
||||||
| 267 | 1928 B | Equalize | [Question](https://codeforces.com/problemset/problem/1928/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1928%20B%20-%20Equalize)
|
| 267 | 1928 A | Rectangle Cutting | [Question](https://codeforces.com/problemset/problem/1928/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1928%20A%20-%20Rectangle%20Cutting)
|
||||||
| 268 | 1929 A | Sasha and the Beautiful Array | [Question](https://codeforces.com/problemset/problem/1929/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1929%20A%20-%20Sasha%20and%20the%20Beautiful%20Array)
|
| 268 | 1928 B | Equalize | [Question](https://codeforces.com/problemset/problem/1928/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1928%20B%20-%20Equalize)
|
||||||
| 269 | 1929 B | Sasha and the Drawing | [Question](https://codeforces.com/problemset/problem/1929/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1929%20B%20-%20Sasha%20and%20the%20Drawing)
|
| 269 | 1929 A | Sasha and the Beautiful Array | [Question](https://codeforces.com/problemset/problem/1929/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1929%20A%20-%20Sasha%20and%20the%20Beautiful%20Array)
|
||||||
| 270 | 1931 A | Recovering a Small String | [Question](https://codeforces.com/problemset/problem/1931/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1931%20A%20-%20Recovering%20a%20Small%20String)
|
| 270 | 1929 B | Sasha and the Drawing | [Question](https://codeforces.com/problemset/problem/1929/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1929%20B%20-%20Sasha%20and%20the%20Drawing)
|
||||||
| 271 | 1931 B | Make Equal | [Question](https://codeforces.com/problemset/problem/1931/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1931%20B%20-%20Make%20Equal)
|
| 271 | 1930 A | Maximise The Score | [Question](https://codeforces.com/problemset/problem/1930/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1930%20A%20-%20Maximise%20The%20Score)
|
||||||
| 272 | 1931 C | Make Equal Again | [Question](https://codeforces.com/problemset/problem/1931/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1931%20C%20-%20Make%20Equal%20Again)
|
| 272 | 1930 B | Permutation Printing | [Question](https://codeforces.com/problemset/problem/1930/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1930%20B%20-%20Permutation%20Printing)
|
||||||
|
| 273 | 1931 A | Recovering a Small String | [Question](https://codeforces.com/problemset/problem/1931/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1931%20A%20-%20Recovering%20a%20Small%20String)
|
||||||
|
| 274 | 1931 B | Make Equal | [Question](https://codeforces.com/problemset/problem/1931/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1931%20B%20-%20Make%20Equal)
|
||||||
|
| 275 | 1931 C | Make Equal Again | [Question](https://codeforces.com/problemset/problem/1931/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1931%20C%20-%20Make%20Equal%20Again)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user