diff options
31 files changed, 507 insertions, 0 deletions
diff --git a/codeforces/DimaAndFriends/main b/codeforces/DimaAndFriends/main Binary files differnew file mode 100755 index 0000000..28ffdf7 --- /dev/null +++ b/codeforces/DimaAndFriends/main diff --git a/codeforces/DimaAndFriends/main.cpp b/codeforces/DimaAndFriends/main.cpp new file mode 100644 index 0000000..245da01 --- /dev/null +++ b/codeforces/DimaAndFriends/main.cpp @@ -0,0 +1,50 @@ +#include<bits/stdc++.h> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +void solve() { + int n, sum = 0; + cin >> n; + for (int i = 0; i < n; i++) { + int x; + cin >> x; + sum += x; + } + cout << (sum % (n + 1)) % 5 << '\n'; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + solve(); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ diff --git a/codeforces/DimaAndFriends/main_input0.txt b/codeforces/DimaAndFriends/main_input0.txt new file mode 100644 index 0000000..6ed281c --- /dev/null +++ b/codeforces/DimaAndFriends/main_input0.txt @@ -0,0 +1,2 @@ +1 +1 diff --git a/codeforces/DimaAndFriends/main_input1.txt b/codeforces/DimaAndFriends/main_input1.txt new file mode 100644 index 0000000..1191247 --- /dev/null +++ b/codeforces/DimaAndFriends/main_input1.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/codeforces/DimaAndFriends/main_input2.txt b/codeforces/DimaAndFriends/main_input2.txt new file mode 100644 index 0000000..a7189af --- /dev/null +++ b/codeforces/DimaAndFriends/main_input2.txt @@ -0,0 +1,2 @@ +2 +3 5 diff --git a/codeforces/DimaAndFriends/main_output0.txt b/codeforces/DimaAndFriends/main_output0.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/codeforces/DimaAndFriends/main_output0.txt @@ -0,0 +1 @@ +3 diff --git a/codeforces/DimaAndFriends/main_output1.txt b/codeforces/DimaAndFriends/main_output1.txt new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/codeforces/DimaAndFriends/main_output1.txt @@ -0,0 +1 @@ +2 diff --git a/codeforces/DimaAndFriends/main_output2.txt b/codeforces/DimaAndFriends/main_output2.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/codeforces/DimaAndFriends/main_output2.txt @@ -0,0 +1 @@ +3 diff --git a/codeforces/PetrAndBook/main b/codeforces/PetrAndBook/main Binary files differnew file mode 100755 index 0000000..42d4232 --- /dev/null +++ b/codeforces/PetrAndBook/main diff --git a/codeforces/PetrAndBook/main.cpp b/codeforces/PetrAndBook/main.cpp new file mode 100644 index 0000000..2d8b340 --- /dev/null +++ b/codeforces/PetrAndBook/main.cpp @@ -0,0 +1,56 @@ +#include<bits/stdc++.h> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +void solve() { + int n, sum = 0; + cin >> n; + vi v(7); + for (auto &x : v) cin >> x; + int ans = 0; + while (1) { + for (auto x : v){ + sum += x; + ans++; + ans %= 7; + if (sum >= n) goto done; + } + } +done: + cout << (ans == 0 ? 7 : ans) << '\n'; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + solve(); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ diff --git a/codeforces/PetrAndBook/main_input0.txt b/codeforces/PetrAndBook/main_input0.txt new file mode 100644 index 0000000..8f27172 --- /dev/null +++ b/codeforces/PetrAndBook/main_input0.txt @@ -0,0 +1,2 @@ +100 +15 20 20 15 10 30 45 diff --git a/codeforces/PetrAndBook/main_input1.txt b/codeforces/PetrAndBook/main_input1.txt new file mode 100644 index 0000000..9d3ea25 --- /dev/null +++ b/codeforces/PetrAndBook/main_input1.txt @@ -0,0 +1,2 @@ +2 +1 0 0 0 0 0 0 diff --git a/codeforces/PetrAndBook/main_output0.txt b/codeforces/PetrAndBook/main_output0.txt new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/codeforces/PetrAndBook/main_output0.txt @@ -0,0 +1 @@ +6 diff --git a/codeforces/PetrAndBook/main_output1.txt b/codeforces/PetrAndBook/main_output1.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/codeforces/PetrAndBook/main_output1.txt @@ -0,0 +1 @@ +1 diff --git a/contests/Round#835/A/main b/contests/Round#835/A/main Binary files differnew file mode 100755 index 0000000..b39bf39 --- /dev/null +++ b/contests/Round#835/A/main diff --git a/contests/Round#835/A/main.cpp b/contests/Round#835/A/main.cpp new file mode 100644 index 0000000..5cff2f4 --- /dev/null +++ b/contests/Round#835/A/main.cpp @@ -0,0 +1,53 @@ +#include<bits/stdc++.h> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +int solve() { + vi v(3); + for (auto &x : v) cin >> x; + for (auto x : v) { + if (x != *min_element(all(v)) && x != *max_element(all(v))) { + return x; + } + } + return 1; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + cout << solve() << '\n'; + } +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ diff --git a/contests/Round#835/A/main_input0.txt b/contests/Round#835/A/main_input0.txt new file mode 100644 index 0000000..20645c8 --- /dev/null +++ b/contests/Round#835/A/main_input0.txt @@ -0,0 +1,10 @@ +9 +5 2 6 +14 3 4 +20 2 1 +1 2 3 +11 19 12 +10 8 20 +6 20 3 +4 1 3 +19 8 4 diff --git a/contests/Round#835/A/main_output0.txt b/contests/Round#835/A/main_output0.txt new file mode 100644 index 0000000..2566454 --- /dev/null +++ b/contests/Round#835/A/main_output0.txt @@ -0,0 +1,9 @@ +5 +4 +2 +2 +12 +10 +6 +3 +8 diff --git a/contests/Round#835/B/main b/contests/Round#835/B/main Binary files differnew file mode 100755 index 0000000..adfafe9 --- /dev/null +++ b/contests/Round#835/B/main diff --git a/contests/Round#835/B/main.cpp b/contests/Round#835/B/main.cpp new file mode 100644 index 0000000..0386895 --- /dev/null +++ b/contests/Round#835/B/main.cpp @@ -0,0 +1,54 @@ +#include<bits/stdc++.h> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +void solve() { + int n; + string s; + cin >> n; + cin >> s; + int mx = 0; + for (auto ch : s) { + mx = max(mx, ch - 'a'); + } + cout << mx + 1 << '\n'; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ diff --git a/contests/Round#835/B/main_input0.txt b/contests/Round#835/B/main_input0.txt new file mode 100644 index 0000000..f0d2637 --- /dev/null +++ b/contests/Round#835/B/main_input0.txt @@ -0,0 +1,11 @@ +5 +1 +a +4 +down +10 +codeforces +3 +bcf +5 +zzzzz diff --git a/contests/Round#835/B/main_output0.txt b/contests/Round#835/B/main_output0.txt new file mode 100644 index 0000000..6dbbf0d --- /dev/null +++ b/contests/Round#835/B/main_output0.txt @@ -0,0 +1,5 @@ +1 +23 +19 +6 +26 diff --git a/contests/Round#835/C/main b/contests/Round#835/C/main Binary files differnew file mode 100755 index 0000000..e256625 --- /dev/null +++ b/contests/Round#835/C/main diff --git a/contests/Round#835/C/main.cpp b/contests/Round#835/C/main.cpp new file mode 100644 index 0000000..a5ec56e --- /dev/null +++ b/contests/Round#835/C/main.cpp @@ -0,0 +1,62 @@ +#include<bits/stdc++.h> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +void solve() { + int n; + cin >> n; + vi v(n); + for (auto &x : v) cin >> x; + vi tmp = v; + sort(all(tmp)); + for (int i = 0; i < n; i++) { + if (v[i] != tmp[n - 1]) { + v[i] = v[i] - tmp[n - 1]; + } else { + v[i] = v[i] - tmp[n - 2]; + } + } + for (auto x : v) { + cout << x << " "; + } + cout << '\n'; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + solve(); + } +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ diff --git a/contests/Round#835/C/main_input0.txt b/contests/Round#835/C/main_input0.txt new file mode 100644 index 0000000..f5f056a --- /dev/null +++ b/contests/Round#835/C/main_input0.txt @@ -0,0 +1,11 @@ +5 +4 +4 7 3 5 +2 +1 2 +5 +1 2 3 4 5 +3 +4 9 4 +4 +4 4 4 4 diff --git a/contests/Round#835/C/main_output0.txt b/contests/Round#835/C/main_output0.txt new file mode 100644 index 0000000..38fa177 --- /dev/null +++ b/contests/Round#835/C/main_output0.txt @@ -0,0 +1,5 @@ +-3 2 -4 -2 +-1 1 +-4 -3 -2 -1 1 +-5 5 -5 +0 0 0 0 diff --git a/contests/Round#835/D/main b/contests/Round#835/D/main Binary files differnew file mode 100755 index 0000000..3098cf7 --- /dev/null +++ b/contests/Round#835/D/main diff --git a/contests/Round#835/D/main.cpp b/contests/Round#835/D/main.cpp new file mode 100644 index 0000000..cd81147 --- /dev/null +++ b/contests/Round#835/D/main.cpp @@ -0,0 +1,68 @@ +#include <algorithm> +#include <bits/stdc++.h> +#include <tuple> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +int countVallyes(vi &v) { + int cnt = 0; + for (int i = 1; i < v.size() - 1; i++) { + if (v[i] < v[i - 1] && v[i] < v[i + 1]) { + cnt++; + } + } + return cnt; +} + +void solve() { + int n; + cin >> n; + vi v(n + 2); + v[0] = INT_MAX; + v[n + 1] = INT_MAX; + for (int i = 1; i < n + 1; i++) { + cin >> v[i]; + } + auto it = unique(all(v)); + vi a = vector<int>(v.begin(), it); + cout << (countVallyes(a) == 1 ? "YES" : "NO") << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ diff --git a/contests/Round#835/D/main_input0.txt b/contests/Round#835/D/main_input0.txt new file mode 100644 index 0000000..5588b9f --- /dev/null +++ b/contests/Round#835/D/main_input0.txt @@ -0,0 +1,13 @@ +6 +7 +3 2 2 1 2 2 3 +11 +1 1 1 2 3 3 4 5 6 6 6 +7 +1 2 3 4 3 2 1 +7 +9 7 4 6 9 9 10 +1 +1000000000 +8 +9 4 4 5 9 4 9 10 diff --git a/contests/Round#835/D/main_output0.txt b/contests/Round#835/D/main_output0.txt new file mode 100644 index 0000000..659e1d2 --- /dev/null +++ b/contests/Round#835/D/main_output0.txt @@ -0,0 +1,6 @@ +YES +YES +NO +YES +YES +NO diff --git a/contests/Round#835/E/main.cpp b/contests/Round#835/E/main.cpp new file mode 100644 index 0000000..68691f8 --- /dev/null +++ b/contests/Round#835/E/main.cpp @@ -0,0 +1,79 @@ +#include <bits/stdc++.h> +#include <tuple> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define push_back pb +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +auto helper(vi &v) { + ll ans = 0, zc = 0; + for (int i = v.size() - 1; i >= 0; i--) { + (v[i] == 0 ? zc++ : ans += zc); + } + return ans; +} + +void solve() { + int n; + cin >> n; + vi v(n), v1(n), v2(n); + for (int i = 0; i < n; i++) { + cin >> v[i]; + } + v1 = v; + v2 = v; + for (auto &x : v1) { + if (x == 0) { + x = 1; + break; + } + } + for (int i = n - 1; i >= 0; i--) { + if (v2[i] == 1) { + v2[i] = 0; + break; + } + } + ll og = helper(v); + ll l = helper(v1); + ll r = helper(v2); + cout << max(og, max(r, l)) << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + |
