Skip to content

Commit

Permalink
holy
Browse files Browse the repository at this point in the history
  • Loading branch information
KryptoCrash committed Jan 17, 2022
1 parent fdc75a2 commit 249911b
Show file tree
Hide file tree
Showing 64 changed files with 5,089 additions and 3 deletions.
27 changes: 27 additions & 0 deletions 121a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;

void solve() {
string s;
cin >> s;
sort(s.begin(), s.end());

cout << s << endl;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t;
cin >> t;
while(t--) solve();

return 0;
}
52 changes: 52 additions & 0 deletions 121b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;

void solve() {
string s;
cin >> s;

ll n = s.length();

bool works = false;

for (int i = n - 1; i >= 1; i--) {
ll x = s[i] - '0';
ll y = s[i - 1] - '0';
if (x + y > 9) {
s[i - 1] = '0' + ((x + y) / 10);

s[i] = '0' + ((x + y) % 10);
works = true;
break;
}
}

if(!works) {
string t;
t += '0' + ((s[0] - '0') + (s[1] - '0'));
for (int i = 2; i < n; i++) {
t += s[i];
}

s = t;
}

cout << s << endl;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t;
cin >> t;
while (t--) solve();

return 0;
}
59 changes: 59 additions & 0 deletions 121c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;

void solve() {
ll n;
cin >> n;

vpi d;

vi k(n);
for(ll i = 0; i < n; i++) {
cin >> k[i];
d.push_back({k[i], 1});
}

vi h(n);
for(ll i = 0; i < n; i++) {
cin >> h[i];
}


for (ll i = 0; i < n; i++) {
d.push_back({k[i] - h[i] + 1, -1});
}

sort(d.begin(), d.end());

ll ans = 0;
ll depth = 0;
ll st = 1;
for (ll i = 0; i <= d.size(); i++) {
if(depth == 0) {
ll sz = (i > 0 ? d[i - 1].first : 0) - st + 1;
ans += (sz * (sz + 1)) / 2;
if(i != d.size()) st = d[i].first;
}

if (i != d.size()) depth += d[i].second;
}

cout << ans << endl;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t;
cin >> t;
while(t--) solve();

return 0;
}
39 changes: 39 additions & 0 deletions 121d.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;

void solve() {
ll n;
cin >> n;

vi a(n);
map<int, int> mp;
for (int i = 0; i < n; i++) {
cin >> a[i];
mp[a[i]]++;
}

sort(a.begin(), a.end());

for (int i = 0; i < 19; i++) {
for (int j = 0; j < 19; j++) {

}
}
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t;
cin >> t;
while(t--) solve();

return 0;
}
Empty file added 121e.cpp
Empty file.
48 changes: 48 additions & 0 deletions 759a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;

void solve() {
ll n;
cin >> n;

vi a(n);
for(ll i = 0; i < n; i++) {
cin >> a[i];
}

ll ans = 1;
bool died = false;

if (a[0]) ans++;

for (ll i = 1; i < n; i++) {
if (!a[i] && !a[i - 1]) died = true;
else if (a[i] && a[i - 1]) ans += 5;
else if (a[i] && !a[i - 1]) ans += 1;

}

if(died) {
cout << -1 << endl;
return;
}

cout << ans << endl;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t;
cin >> t;
while(t--) solve();

return 0;
}
38 changes: 38 additions & 0 deletions 759b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;

void solve() {
ll n;
cin >> n;

vi a(n);
for (ll i = 0; i < n; i++) {
cin >> a[i];
}

ll rmx = 0;

ll cnt = 0;
for (ll i = n - 1; i >= 0; i--) {
if (a[i] > rmx) cnt++, rmx = a[i];
}

cout << cnt - 1 << endl;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t;
cin >> t;
while (t--) solve();

return 0;
}
57 changes: 57 additions & 0 deletions 759c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;

void solve() {
ll n, k;
cin >> n >> k;

vi a;
vi b;
for (ll i = 0; i < n; i++) {
ll c;
cin >> c;
if (c == 0) continue;
if (c > 0) a.push_back(c);
if (c < 0) b.push_back(-c);
}

sort(a.begin(), a.end(), greater<ll>());
sort(b.begin(), b.end(), greater<ll>());
vi trips;

for (ll i = 0; i < a.size(); i += k) {
trips.push_back(a[i]);
}

for (ll i = 0; i < b.size(); i += k) {
trips.push_back(b[i]);
}

ll ans = 0;
sort(trips.begin(), trips.end(), greater<ll>());

for(ll i : trips) {
ans += i * 2;
}

if(trips.size() > 0) ans -= trips[0];

cout << ans << endl;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t;
cin >> t;
while(t--) solve();

return 0;
}
57 changes: 57 additions & 0 deletions 759cbad.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using vb = vector<bool>;

void solve() {
ll n, k;
cin >> n >> k;

vi a;
vi b;
for (ll i = 0; i < n; i++) {
ll c;
cin >> c;
if (c == 0) continue;
if (c > 0) a.push_back(c);
if (c < 0) b.push_back(-c);
}

sort(a.begin(), a.end(), greater<ll>());
sort(b.begin(), b.end(), greater<ll>());
vi trips;

for (ll i = 0; i < a.size(); i += k) {
trips.push_back(a[i]);
}

for (ll i = 0; i < b.size(); i += k) {
trips.push_back(b[i]);
}

ll ans = 0;
sort(trips.begin(), trips.end(), greater<ll>());

for (ll i : trips) {
ans += i * 2;
}

ans -= trips[0];

cout << ans << endl;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t;
cin >> t;
while (t--) solve();

return 0;
}
Loading

0 comments on commit 249911b

Please sign in to comment.