diff --git a/Codes/1955 A - Yogurt Sale/1955A.cpp b/Codes/1955 A - Yogurt Sale/1955A.cpp new file mode 100644 index 0000000..7d5122e --- /dev/null +++ b/Codes/1955 A - Yogurt Sale/1955A.cpp @@ -0,0 +1,69 @@ +#include +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"<>= 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 dbg(...) +#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 void __print(const A &x); template void __print(const pair &p); +template void __print(const A &x) {bool f=1; cerr << '['; for (const auto &i : x) {cerr << (f ? "" : ","), __print(i); f = 0;} cerr << ']';} +template void __print(const pair &p) {cerr << '('; __print(p.first); cerr << ','; __print(p.second); cerr << ')';} +template void _print(const Head &H, const Tail &...T) { __print(H); if (sizeof...(T)) cerr << ", "; _print(T...);} +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n,a,b; + cin>>n>>a>>b; + if(2*a<=b) + cout<> TC; + while (TC--) + solve(); +} \ No newline at end of file diff --git a/Codes/1955 B - Progressive Square/1955B.cpp b/Codes/1955 B - Progressive Square/1955B.cpp new file mode 100644 index 0000000..775fc62 --- /dev/null +++ b/Codes/1955 B - Progressive Square/1955B.cpp @@ -0,0 +1,90 @@ +#include +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"<>= 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 dbg(...) +#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 void __print(const A &x); template void __print(const pair &p); +template void __print(const A &x) {bool f=1; cerr << '['; for (const auto &i : x) {cerr << (f ? "" : ","), __print(i); f = 0;} cerr << ']';} +template void __print(const pair &p) {cerr << '('; __print(p.first); cerr << ','; __print(p.second); cerr << ')';} +template void _print(const Head &H, const Tail &...T) { __print(H); if (sizeof...(T)) cerr << ", "; _print(T...);} +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + ll n,c,d; + cin>>n>>c>>d; + mapm; + for(ll i=0; i>x; + m[x]++; + } + ll p=m.begin()->ff; + m[p]--; + for(ll i=0; i> TC; + while (TC--) + solve(); +} \ No newline at end of file diff --git a/Codes/1955 C - Inhabitant of the Deep Sea/1955C.cpp b/Codes/1955 C - Inhabitant of the Deep Sea/1955C.cpp new file mode 100644 index 0000000..49c270d --- /dev/null +++ b/Codes/1955 C - Inhabitant of the Deep Sea/1955C.cpp @@ -0,0 +1,123 @@ +#include +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"<>= 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 dbg(...) +#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 void __print(const A &x); template void __print(const pair &p); +template void __print(const A &x) {bool f=1; cerr << '['; for (const auto &i : x) {cerr << (f ? "" : ","), __print(i); f = 0;} cerr << ']';} +template void __print(const pair &p) {cerr << '('; __print(p.first); cerr << ','; __print(p.second); cerr << ')';} +template void _print(const Head &H, const Tail &...T) { __print(H); if (sizeof...(T)) cerr << ", "; _print(T...);} +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + ll n,k; + cin>>n>>k; + dequed; + for(int i=0; i>x; + d.pb(x); + } + int f=1, ans=0; + while(k>0 && sz(d)) + { + if(sz(d)==1) + { + if(d.front()<=k) + ans++; + break; + } + int x=d.front(); + int y=d.back(); + int z=min(x,y); + d.pop_front(); + d.pop_back(); + if(f) + { + if(z==x) + { + if(k<2*z-1) break; + k-=2*z-1; + y-=z-1; + f=0; + d.push_back(y); + ans++; + } + else + { + if(k<2*z) break; + k-=2*z; + x-=z; + d.push_front(x); + ans++; + } + } + else + { + if(z==y) + { + if(k<2*z-1) break; + k-=2*z-1; + x-=z-1; + f=1; + d.push_front(x); + ans++; + } + else + { + if(k<2*z) break; + k-=2*z; + y-=z; + d.push_back(y); + ans++; + } + } + } + cout<> TC; + while (TC--) + solve(); +} \ No newline at end of file diff --git a/Readme.md b/Readme.md index c14b54a..dc6ac4c 100644 --- a/Readme.md +++ b/Readme.md @@ -291,6 +291,9 @@ This repository contains my solutions of Codeforces problems. They are in C++ la | 279 | 1933 B | Turtle Math Fast Three Task | [Question](https://codeforces.com/problemset/problem/1933/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1933%20B%20-%20Turtle%20Math%20Fast%20Three%20Task) | 280 | 1933 C | Turtle Fingers Count the Values of k | [Question](https://codeforces.com/problemset/problem/1933/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1933%20C%20-%20Turtle%20Fingers%20Count%20the%20Values%20of%20k) | 281 | 1945 A | Setting up Camp | [Question](https://codeforces.com/problemset/problem/1945/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1945%20A%20-%20Setting%20up%20Camp) +| 282 | 1955 A | Yogurt Sale | [Question](https://codeforces.com/problemset/problem/1955/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1955%20A%20-%20Yogurt%20Sale) +| 283 | 1955 B | Progressive Square | [Question](https://codeforces.com/problemset/problem/1955/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1955%20B%20-%20Progressive%20Square) +| 284 | 1955 C | Inhabitant of the Deep Sea | [Question](https://codeforces.com/problemset/problem/1955/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1955%20C%20-%20Inhabitant%20of%20the%20Deep%20Sea)