Codeforces Round 824 (Div. 2) 解题报告
对应场次为 CF1735
A. Working Week
题目大意
你接下来有 \(n(6 \le n \le 10^9)\) 个工作日 必须在第 \(n\) 天休假 你可以另外再选两天休假
设你工作的三段长度为 \(l_1, l_2, l_3\)
求 \(\max(\min(\left|l_2 - l_1\right|, \left|l_3 - l_2\right|,\left|l_1 - l_3\right|))\)
Solution
懒得打 \(\LaTeX\) 了

点击查看代码
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read() {
int xr = 0, F = 1;
char cr;
while (cr = getchar(), cr < '0' || cr > '9') if (cr == '-') F = -1;
while (cr >= '0' && cr <= '9')
xr = (xr << 3) + (xr << 1) + (cr ^ 48), cr = getchar();
return xr * F;
}
void write(ll x) {
char ws[51];
int wt = 0;
if (x < 0) putchar('-'), x = -x;
do {
ws[++wt] = x % 10 + '0';
x /= 10;
} while (x);
for (int i = wt; i; --i) putchar(ws[i]);
}
namespace steven24 {
int T, n;
void main() {
T = read();
while (T--) {
n = read();
write((n - 3) / 3 - 1), putchar('\n');
}
}
}
int main() {
steven24::main();
return 0;
}
B. Tea with Tangerines
tangerine 橘子
题目大意
给定 \(n(1 \le n \le 100)\) 个数 你可以操作一次把一个数变成两个相加等于它的数 求最少操作多少次能使得不存在 \((x, y)\) 使得 \(2x \le y\)
Solution
通过观察样例解释不难发现最小的那个数一定是不要裂开的
然后就可以把最小数的二倍作为基准去劈其它的数
发现比较均匀地劈一定是最优的 因为这样会让劈开的几段中最长的最短
点击查看代码
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int read() {
ll xr = 0, F = 1;
char cr;
while (cr = getchar(), cr < '0' || cr > '9') if (cr == '-') F = -1;
while (cr >= '0' && cr <= '9')
xr = (xr << 3) + (xr << 1) + (cr ^ 48), cr = getchar();
return xr * F;
}
void write(ll x) {
char ws[51];
int wt = 0;
if (x < 0) putchar('-'), x = -x;
do {
ws[++wt] = x % 10 + '0';
x /= 10;
} while (x);
for (int i = wt; i; --i) putchar(ws[i]);
}
namespace steven24 {
const int N = 521;
int a[N];
int T, n;
void main() {
T = read();
while (T--) {
n = read();
for (int i = 1; i <= n; ++i) a[i] = read();
int minn = *min_element(a + 1, a + 1 + n);
minn <<= 1;
--minn;
int ans = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] > minn) {
ans += a[i] / minn - 1;
if (a[i] % minn) ++ans;
}
}
write(ans), putchar('\n');
}
}
}
int main() {
steven24::main();
return 0;
}

浙公网安备 33010602011771号