From de565daf8423226684ac394b0365e58d620e870e Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Fri, 15 Dec 2023 01:23:22 +0600 Subject: [PATCH] added 1857C --- 1857C Assembly via Minimums/1857C.cpp | 94 +++++++++++++++++++++++++++ Readme.md | 1 + 2 files changed, 95 insertions(+) create mode 100644 1857C Assembly via Minimums/1857C.cpp diff --git a/1857C Assembly via Minimums/1857C.cpp b/1857C Assembly via Minimums/1857C.cpp new file mode 100644 index 0000000..9198473 --- /dev/null +++ b/1857C Assembly via Minimums/1857C.cpp @@ -0,0 +1,94 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll 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() + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(unordered_set v) {cerr<<"[ "; for(T i : v) {_print(i); cerr<<" ";} cerr<<"]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multimap v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(unordered_map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n; + cin>>n; + int m=n*(n-1)/2; + mapmp; + vectorv; + for(int i=0; i>x; + mp[x]++; + } + for(auto it:mp) + { + int num=it.first; + int ct=it.second; + while(ct>0) + { + v.push_back(num); + ct=ct-n+sz(v); + } + } + for(auto x:v) + cout<> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/Readme.md b/Readme.md index 93edb65..ee41cd9 100644 --- a/Readme.md +++ b/Readme.md @@ -154,6 +154,7 @@ Feel free to check these codes out. | 1855A | Dalton the Teacher | [Question](https://codeforces.com/contest/1855/problem/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1855A%20Dalton%20the%20Teacher/1855A.cpp) | 1856B | Good Arrays | [Question](https://codeforces.com/problemset/problem/1856/B) | [Solution] | 1857A | Array Coloring | [Question](https://codeforces.com/problemset/problem/1857/A) | [Solution] +| 1857C | Assembly via Minimums | [Question](https://codeforces.com/problemset/problem/1857/C) | [Solution] | 1858A | Buttons | [Question](https://codeforces.com/problemset/problem/1858/A) | [Solution] | 1859A | United We Stand | [Question](https://codeforces.com/problemset/problem/1859/A) | [Solution] | 1862A | Gift Carpet | [Question](https://codeforces.com/problemset/problem/1862/A) | [Solution]