目录
A - Anton and Danik
题目链接https://codeforces.com/problemset/problem/734/A
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int inf = 1e8 + 10;
const int mac = 1e5 + 10;
char s[mac];
int main()
{
IOS;
int n, d;
cin >> n;
cin >> s;
int a1 = 0, d1 = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'D') d1++;
else a1++;
}
if (a1 > d1) cout << "Anton" << endl;
else if (a1 < d1) cout << "Danik" << endl;
else cout << "Friendship" << endl;
return 0;
}
B - Anton and Digits
题目链接https://codeforces.com/problemset/problem/734/B
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
#define ll long long
const int inf = 1e8 + 10;
const int mac = 1e5 + 10;
char s[mac];
int main()
{
IOS;
int k2, k3, k5, k6;
ll sum = 0;
cin >> k2 >> k3 >> k5 >> k6;
while (k2 && k5 && k6) {
k2--; k5--; k6--;
sum += 256;
}
while (k2 && k3) {
k2--; k3--;
sum += 32;
}
cout << sum << endl;
return 0;
}
C - Anton and Making Potions
题目链接https://codeforces.com/problemset/problem/734/C
#include <bits/stdc++.h>
using namespace std;
const int mac = 2e5 + 10;
#define IOS ios::sync_with_stdio(false)
#define ll long long
const ll inf = 1e18 + 10;
int a[mac], b[mac], c[mac], d[mac];
int main()
{
IOS;
int n, m, k;
cin >> n >> m >> k;
int x, s;
cin >> x >> s;
for (int i = 1; i <= m; i++) cin >> a[i];
for (int i = 1; i <= m; i++) cin >> b[i];
for (int i = 1; i <= k; i++) cin >> c[i];
for (int i = 1; i <= k; i++) cin >> d[i];
ll ans = (ll)(n - c[upper_bound(d + 1, d + 1 + k, s) - d - 1]) * x;
for (int i = 1; i <= m; i++) {
if (b[i] > s) continue;
ans = min(ans, (ll)(n - c[upper_bound(d + 1, d + 1 + k, s - b[i]) - d - 1]) * a[i]);
}
cout << ans << endl;
return 0;
}
D - Ostap and Grasshopper
题目链接https://codeforces.com/problemset/problem/735/A
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int inf = 1e8 + 10;
const int mac = 1e5 + 10;
char s[mac];
int main()
{
IOS;
int n, k;
cin >> n >> k;
cin >> s;
int head = 0, st, fa, mark = 0;
for (int i = 0; i < n; i++)
if (s[i] == 'G') st = i;
else if (s[i] == 'T') fa = i;
head = st;
while (head < n) {
head += k;
if (head >= n) break;
if (head == fa) {
mark = 1;
cout << "YES" << endl;
return 0;
}
if (s[head] == '#') break;
}
head = st;
while (head >= 0) {
head -= k;
if (head < 0) break;
if (head == fa) {
mark = 1; cout << "YES" << endl;
return 0;
}
if (s[head] == '#') break;
}
if (!mark) cout << "NO" << endl;
return 0;
}
E - Urbanization
题目链接https://codeforces.com/problemset/problem/735/B
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false)
const int inf = 1e8 + 10;
const int mac = 1e5 + 10;
char s[mac];
int a[mac];
bool cmp(int x, int y)
{
return x > y;
}
int main()
{
//IOS;
int n, n1, n2;
cin >> n >> n1 >> n2;
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
sort(a + 1, a + 1 + n, cmp);
double s1 = 0, s2 = 0;
if (n1 > n2) swap(n1, n2);
int q1 = n1, q2 = n2;
int i = 1;
while (n1) {
n1--; s1 += a[i++];
}
while (n2) {
n2--; s2 += a[i++];
}
s1 /= q1, s2 /= q2;
double ans = s1 + s2;
printf("%.8f\n", ans);
return 0;
}
F - Tennis Championship
题目链接https://codeforces.com/problemset/problem/735/C
#include <bits/stdc++.h>
using namespace std;
const int mac = 2e5 + 10;
#define IOS ios::sync_with_stdio(false)
#define ll long long
const ll inf = 1e18 + 10;
ll f[mac];
int main()
{
IOS;
ll n;
cin >> n;
int i = 1;
f[0] = 1, f[1] = 2;
while (f[i] < inf) {
i++;
f[i] = f[i - 1] + f[i - 2];
}
i = 1;
while (n >= f[i]) {
i++;
}
cout << i - 1 << endl;
return 0;
}