题目 › egoi26-cakes

Cakes

EGOI 2026 · 2026-05 · L3 困难 · C++17 · 时限 2 秒 · 子任务取最低分

查看原题跳到结果

题面

来源:EGOI 2026 官方 PDF。模型收到的是由同一份 Typst 源文件转换的文字。

EGOI 2026 Cakes 官方题面第 1 页EGOI 2026 Cakes 官方题面第 2 页EGOI 2026 Cakes 官方题面第 3 页

结果

Kimi K3.1 ProKimi

auto(max)

3/3

解出的采样 ↑

  • 100采样 1 · 解出
  • 100采样 2 · 解出
  • 100采样 3 · 解出
  • 7.5k平均输出 token(含思考) ↓
  • 25.1输出速度 tokens/s ↑
  • 262 秒延迟 ↓

DeepSeek Flash V4.1-1017DeepSeek

auto(high)

3/3

解出的采样 ↑

  • 100采样 1 · 解出
  • 100采样 2 · 解出
  • 100采样 3 · 解出
  • 12.2k平均输出 token(含思考) ↓
  • 210.8输出速度 tokens/s ↑
  • 57 秒延迟 ↓

MiniMax M3.1 FlashMiniMax

auto(max)

2/3

解出的采样 ↑

  • 0.0采样 1 · 答案错误
  • 100采样 2 · 解出
  • 100采样 3 · 解出
  • 10.8k平均输出 token(含思考) ↓
  • 163.7输出速度 tokens/s ↑
  • 53 秒延迟 ↓

↑ 越大越好,↓ 越小越好。得分 0–100,按官方时限判定,所有测试点都满分才算解出。CPU 时间 / 官方解为解出的答案在官方解最慢的 3 个测试点上的 CPU 时间之比(几何平均),只比较官方解至少需要 0.05 秒的题;复杂度按增长幂次相对官方解分类。判题与计分见 原理。

代码

Kimi K3.1 Pro · 采样 1 · 91 行
#include <bits/stdc++.h>
using namespace std;

using int64 = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, Q;
    cin >> N >> Q;

    vector<int> a(N);
    int maxA = 0;
    for (int &x : a) {
        cin >> x;
        maxA = max(maxA, x);
    }

    vector<int> frequency(maxA + 1, 0);
    for (int x : a) {
        ++frequency[x];
    }

    // atLeast[x] = number of topping types having at least x pieces.
    vector<int> atLeast(maxA + 2, 0);
    for (int x = maxA; x >= 1; --x) {
        atLeast[x] = atLeast[x + 1] + frequency[x];
    }

    /*
       For a fixed tastiness t, exactly k cakes are possible iff:
         1. k * t >= maxA, so every topping type fits within the
            per-cake limit of t pieces;
         2. sum_i floor(a_i / t) >= k, allowing every cake to receive
            a designated group of t equal toppings.

       Thus, for this t, all feasible k form the interval
         [ceil(maxA / t), sum_i floor(a_i / t)].
    */
    vector<pair<int64, int64>> intervals;

    for (int t = 1; t <= maxA; ++t) {
        int64 fullGroups = 0;

        // floor(a/t) counts the positive multiples m*t not exceeding a.
        for (int multiple = t; multiple <= maxA; multiple += t) {
            fullGroups += atLeast[multiple];
        }

        int64 lower = (maxA + t - 1) / t;
        if (lower <= fullGroups) {
            intervals.push_back({lower, fullGroups});
        }
    }

    sort(intervals.begin(), intervals.end());

    vector<pair<int64, int64>> merged;
    for (const auto &interval : intervals) {
        if (merged.empty() ||
            interval.first > merged.back().second + 1) {
            merged.push_back(interval);
        } else {
            merged.back().second =
                max(merged.back().second, interval.second);
        }
    }

    while (Q--) {
        int64 k;
        cin >> k;

        size_t low = 0, high = merged.size();
        while (low < high) {
            size_t mid = (low + high) / 2;
            if (merged[mid].first <= k) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }

        bool possible =
            low > 0 && k <= merged[low - 1].second;

        cout << (possible ? "YES" : "NO") << '\n';
    }

    return 0;
}