目录
A - Straight «A»
题目链接https://codeforces.com/problemset/problem/810/A
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define ll long long
const int inf = 4e8 + 10;
const int mac = 1e5 + 10;
int main()
{
IOS;
int n, m, x;
cin >> n >> m;
double sum = 0;
for (int i = 1; i <= n; i++) {
cin >> x;
sum += x;
}
if (sum/n >= (double)m - 0.5) {
cout << 0 << endl; return 0;
}
int p = 0;
while (1) {
n++; sum += m; p++;
if (sum / n >= (double)m - 0.5) {
cout << p << endl; return 0;
}
}
return 0;
}
B - Summer sell-off
题目链接https://codeforces.com/problemset/problem/810/B
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define ll long long
const int inf = 4e8 + 10;
const int mac = 1e5 + 10;
struct node
{
ll nb, ren;
}a[mac];
bool cmp(node a,node b)
{
ll p=a.nb*2,p1=b.nb*2;
if (p>a.ren) p=a.ren;
if (p1>b.ren) p1=b.ren;
return p-a.nb>p1-b.nb;
}
int main()
{
IOS;
int n, m, x, y;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i].nb >> a[i].ren;
}
ll ans = 0;
sort(a + 1, a + 1 + n,cmp);
for (int i = 1; i <= n; i++) {
if (m == 0) break;
if (a[i].nb >= a[i].ren) continue;
if (a[i].nb == 0) continue;
else {
m--; a[i].nb *= 2;
}
}
for (int i = 1; i <= n; i++) {
ans += (a[i].nb > a[i].ren) ? a[i].ren : a[i].nb;
}
cout << ans << endl;
return 0;
}
C - Do you want a date?
题目链接https://codeforces.com/problemset/problem/810/C
D - Sagheer and Crossroads
题目链接https://codeforces.com/problemset/problem/812/A
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define ll long long
const int inf = 4e8 + 10;
const int mac = 2e5 + 10;
int l[10], r[10], s[10], p[10];
int main()
{
IOS;
int mark = 0;
for (int i = 1; i <= 4; i++) {
cin >> l[i] >> s[i] >> r[i] >> p[i];
}
for (int i = 1; i <= 4; i++) {
if (p[i]) {
if (i == 1) {
if (l[1] || s[1] || r[1]) {
cout << "YES" << endl; return 0;
}
if (r[4] || l[2] || s[3]) {
cout << "YES" << endl; return 0;
}
}
else if (i == 2) {
if (l[2] || s[2] || r[2]) {
cout << "YES" << endl; return 0;
}
if (r[1] || l[3] || s[4]) {
cout << "YES" << endl; return 0;
}
}
else if (i == 3) {
if (l[3] || s[3] || r[3]) {
cout << "YES" << endl; return 0;
}
if (r[2] || l[4] || s[1]) {
cout << "YES" << endl; return 0;
}
}
else {
if (l[4] || s[4] || r[4]) {
cout << "YES" << endl; return 0;
}
if (r[3] || l[1] || s[2]) {
cout << "YES" << endl; return 0;
}
}
}
}
cout << "NO" << endl;
return 0;
}
E - Sagheer, the Hausmeister
题目链接https://codeforces.com/problemset/problem/812/B