initial commit
This commit is contained in:
commit
7aacde99f4
12 changed files with 296 additions and 0 deletions
45
codeforces/991/a.cc
Normal file
45
codeforces/991/a.cc
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(x) for (size_t i = 0; i < (x).size(); ++i)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cerr << #x << " = " << (x) << '\n'
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
void solve() {
|
||||
int n, m;
|
||||
cin >> n >> m;
|
||||
size_t length = 0, words = 0;
|
||||
bool order = true;
|
||||
string s;
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
cin >> s;
|
||||
if (length + s.size() <= m && order) {
|
||||
dbg(m);
|
||||
length += s.size();
|
||||
++words;
|
||||
} else {
|
||||
order = false;
|
||||
}
|
||||
}
|
||||
cout << words << '\n';
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
22
codeforces/991/a.in
Normal file
22
codeforces/991/a.in
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
5
|
||||
3 1
|
||||
a
|
||||
b
|
||||
c
|
||||
2 9
|
||||
alpha
|
||||
beta
|
||||
4 12
|
||||
hello
|
||||
world
|
||||
and
|
||||
codeforces
|
||||
3 2
|
||||
ab
|
||||
c
|
||||
d
|
||||
3 2
|
||||
abc
|
||||
ab
|
||||
a
|
||||
|
||||
0
codeforces/991/a.out
Normal file
0
codeforces/991/a.out
Normal file
54
codeforces/991/b.cc
Normal file
54
codeforces/991/b.cc
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(x) for (size_t i = 0; i < (x).size(); ++i)
|
||||
#define FORI(x) for (size_t i = 0; i < (x); ++i)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cerr << #x << " = " << (x) << '\n'
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
void solve() {
|
||||
int n;
|
||||
cin >> n;
|
||||
vector<int> a(n);
|
||||
|
||||
int total = 0;
|
||||
FOR(a) {
|
||||
int x;
|
||||
cin >> x;
|
||||
a[i] = x;
|
||||
total += x;
|
||||
}
|
||||
|
||||
long long odds = 0, evens = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
(i & 1 ? odds : evens) += a[i];
|
||||
}
|
||||
int odd_count = n >> 1, even_count = (n >> 1) + (n & 1);
|
||||
|
||||
if (odds % odd_count == 0 && evens % even_count == 0 &&
|
||||
odds / odd_count == evens / even_count) {
|
||||
cout << "YES\n";
|
||||
} else {
|
||||
cout << "NO\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
17
codeforces/991/b.in
Normal file
17
codeforces/991/b.in
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
8
|
||||
3
|
||||
3 2 1
|
||||
3
|
||||
1 1 3
|
||||
4
|
||||
1 2 5 4
|
||||
4
|
||||
1 6 6 1
|
||||
5
|
||||
6 2 1 4 2
|
||||
4
|
||||
1 4 2 1
|
||||
5
|
||||
3 1 2 1 3
|
||||
3
|
||||
2 4 2
|
||||
8
codeforces/991/b.out
Normal file
8
codeforces/991/b.out
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
53
codeforces/991/c.cc
Normal file
53
codeforces/991/c.cc
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(x) for (size_t i = 0; i < (x).size(); ++i)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cerr << #x << " = " << (x) << '\n'
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
void solve() {
|
||||
string n;
|
||||
cin >> n;
|
||||
|
||||
long long total = 0, twos = 0, threes = 0;
|
||||
|
||||
for (char c : n) {
|
||||
int digit = c - '0';
|
||||
if (digit == 2)
|
||||
++twos;
|
||||
else if (digit == 3)
|
||||
++threes;
|
||||
total += digit;
|
||||
}
|
||||
|
||||
for (long long i = 0; i < std::min(10LL, twos + 1); ++i) {
|
||||
for (long long j = 0; j < std::min(10LL, threes + 1); ++j) {
|
||||
if ((total + i * 2 + j * 6) % 9 == 0) {
|
||||
cout << "YES\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << "NO\n";
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
10
codeforces/991/c.in
Normal file
10
codeforces/991/c.in
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
9
|
||||
123
|
||||
322
|
||||
333333333333
|
||||
9997
|
||||
5472778912773
|
||||
1234567890
|
||||
23
|
||||
33
|
||||
52254522632
|
||||
9
codeforces/991/c.out
Normal file
9
codeforces/991/c.out
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
NO
|
||||
YES
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
YES
|
||||
48
usaco/blocks.cc
Normal file
48
usaco/blocks.cc
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(x) for (size_t i = 0; i < (x).size(); ++i)
|
||||
|
||||
#ifndef LOCAL
|
||||
#define dbg(x) cerr << #x << " = " << (x) << '\n'
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
#define PROBLEM_NAME "blocks"
|
||||
|
||||
void solve() {
|
||||
int N;
|
||||
cin >> N;
|
||||
vector<int> ans(26, 0);
|
||||
|
||||
for(int i = 0; i < N; ++i) {
|
||||
string left, right;
|
||||
cin >> left >> right;
|
||||
vector<int> count_left(26, 0);
|
||||
for(char c : left) count_left[c - 'a']++;
|
||||
vector<int> count_right(26, 0);
|
||||
for(char c : right) count_right[c - 'a']++;
|
||||
for(int j = 0; j < 26; ++j) {
|
||||
ans[j] += max(count_left[j], count_right[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for(int count : ans) {
|
||||
cout << count << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
freopen(PROBLEM_NAME ".in", "r", stdin);
|
||||
freopen(PROBLEM_NAME ".out", "w", stdout);
|
||||
|
||||
solve();
|
||||
|
||||
return 0;
|
||||
}
|
||||
4
usaco/blocks.in
Normal file
4
usaco/blocks.in
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
3
|
||||
fox box
|
||||
dog cat
|
||||
car bus
|
||||
26
usaco/blocks.out
Normal file
26
usaco/blocks.out
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
2
|
||||
2
|
||||
2
|
||||
1
|
||||
0
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
2
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
1
|
||||
0
|
||||
0
|
||||
Loading…
Add table
Add a link
Reference in a new issue