diff --git a/1849B Monsters/1849B.cpp b/1849B Monsters/1849B.cpp new file mode 100644 index 0000000..5ebd76f --- /dev/null +++ b/1849B Monsters/1849B.cpp @@ -0,0 +1,93 @@ +#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(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 << "]";} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +bool cmp(paira, pairb) +{ + if(a.ff==b.ff) + return a.ssb.first; +} + + +void solve() +{ + int n,k; + cin>>n>>k; + vector>v; + for(int i=1; i<=n; ++i) + { + int x; + cin>>x; + if(x%k) + x%=k; + else + x=k; + v.pb({x,i}); + } + sort(all(v),cmp); + for(auto it:v) + cout<> TC; + while (TC--) + solve(); +} \ No newline at end of file diff --git a/Readme.md b/Readme.md index d4f08b1..56bcfdf 100644 --- a/Readme.md +++ b/Readme.md @@ -141,6 +141,7 @@ Feel free to check these codes out. | 1846C | Rudolf and the Another Competition | [Question](https://codeforces.com/contest/1846/problem/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1846C%20Rudolf%20and%20the%20Another%20Competition/1846C.cpp) | 1848A | Vika and Her Friends | [Question](https://codeforces.com/contest/1848/problem/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1848A%20Vika%20and%20Her%20Friends/1848A.cpp) | 1849A | Morning Sandwich | [Question](https://codeforces.com/problemset/problem/1849/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1849A%20Morning%20Sandwich/1849A.cpp) +| 1849B | Monsters | [Question](https://codeforces.com/problemset/problem/1849/B) | [Solution] | 1850A | To My Critics | [Question](https://codeforces.com/contest/1850/problem/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1850A%20To%20My%20Critics/1850A.cpp) | 1850B | Ten Words of Wisdom | [Question](https://codeforces.com/contest/1850/problem/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1850B%20Ten%20Words%20of%20Wisdom/1850B.cpp) | 1850C | Word on the Paper | [Question](https://codeforces.com/contest/1850/problem/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/blob/master/1850C%20Word%20on%20the%20Paper/1850C.cpp)