比赛链接:Here
835A. Key races
理解题意,然后根据情况输出
835B. The number on the board
根据题目意思贪心处理下,总和和k的关系,问你要改几位,改成9就好了啊
const int N = 100000 + 10;int a[N];bool cmp(int a, int b) {return a > b;}int main() {cin.tie(nullptr)->sync_with_stdio(false);ll k; string s;cin >> k >> s;int n = int(s.size());int cnt = 0;for (int i = 0; i < n; i++) {cnt += s[i] - '0';a[i] = 9 - (s[i] - '0');}sort(a, a + n, cmp);for (int i = 1; i < n; i++) a[i] += a[i - 1];if (cnt >= k) cout << "0";else {int ans = k - cnt;for (int i = 0; i < n; ++i) {if (a[i] >= ans) {cout << i + 1;break;}}}}
835C. Star sky
尝试写转移方程,但发现没必要那么麻烦,考虑二/三维前缀和,由于坐标范围在 之间那么写暴力也没事
const int N = 110;int sum[N][N][12];int main() {cin.tie(nullptr)->sync_with_stdio(false);int n, q, c;cin >> n >> q >> c;for (int i = 1; i <= n; ++i) {int x, y, s;cin >> x >> y >> s;sum[x][y][s] += 1;}for (int i = 1; i <= 100; ++i)for (int j = 1; j <= 100; ++j)for (int k = 0; k <= c; k++)sum[i][j][k] += sum[i - 1][j][k] + sum[i][j - 1][k] - sum[i - 1][j - 1][k];while (q--) {int t, sx, sy, ex, ey;cin >> t >> sx >> sy >> ex >> ey;int ans = 0;for (int i = 0; i <= c; ++i) {int x = (i + t) % (c + 1);ans += x * (sum[ex][ey][i] - sum[sx - 1][ey][i] - sum[ex][sy - 1][i] + sum[sx - 1][sy - 1][i]);// cout << "demo: " << ans << "\n";}cout << ans << "\n";}}
