Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://codeforces.com/problemset/problem/1144/A
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin >> t;
- while (t--) {
- string s;
- vector<int> a(26, 0);
- cin >> s;
- for (int i = 0; i < s.size(); i++) {
- a[s[i] - 'a']++;
- }
- int sum = 0, mxl = 0, l = 0;
- bool isDouble = false;
- for (int i = 0; i < 26; i++) {
- if (a[i] > 1) {
- isDouble = true;
- }
- if (a[i] == 1) {
- sum++;
- l++;
- if (mxl < l) mxl = l;
- } else {
- l = 0;
- }
- }
- if (mxl == sum && !isDouble) {
- cout << "Yes\n";
- } else {
- cout << "No\n";
- }
- }
- return 0;
- }
- https://codeforces.com/problemset/problem/129/A
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n, sum = 0, chet = 0, nechet = 0;
- cin >> n;
- while (n--) {
- int x;
- cin >> x;
- x % 2 == 0 ? chet++ : nechet++;
- sum += x;
- }
- cout << (sum % 2 == 0 ? chet : nechet);
- return 0;
- }
- https://codeforces.com/problemset/problem/1450/A
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin >> t;
- while (t--) {
- int n;
- string s;
- cin >> n >> s;
- int t_count = 0;
- for (int i = 0; i < n; i++) {
- if (s[i] != 't') {
- cout << s[i];
- } else {
- t_count++;
- }
- }
- while (t_count--) cout << 't';
- cout << "\n";
- }
- return 0;
- }
- https://codeforces.com/problemset/problem/1602/A
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin >> t;
- while (t--) {
- string s;
- cin >> s;
- char mn = 'z';
- for (int i = 0; i < s.size(); i++) {
- if (mn > s[i]) mn = s[i];
- }
- cout << mn << " ";
- for (int i = 0; i < s.size(); i++) {
- if (mn == s[i]) {
- mn = '-';
- continue;
- }
- cout << s[i];
- }
- cout << "\n";
- }
- return 0;
- }
- https://codeforces.com/problemset/problem/984/A
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- vector<int> a(n);
- for (int i = 0; i < n; i++) cin >> a[i];
- sort(a.rbegin(), a.rend());
- cout << a[n / 2];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement