QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499007#9133. Function with Many Maximumsucup-team3215AC ✓22ms9212kbC++20951b2024-07-30 22:56:272024-07-30 22:56:28

Judging History

你现在查看的是最新测评结果

  • [2024-07-30 22:56:28]
  • 评测
  • 测评结果:AC
  • 用时:22ms
  • 内存:9212kb
  • [2024-07-30 22:56:27]
  • 提交

answer

#include <iostream>
#include <vector>

using namespace std;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int64_t l = 1e11, c = 446000, k = 0;
  vector<int64_t> a;
  while (1) {
    bool ok = 0;
    for (int b = 1; b < 5; ++b) {
      int64_t d = (2 * l * b + c - b - 1) / (c - b), req = d * (c - b) - 2 * l * b, s = 0, mx = d;
      if (l + d >= 1e12) break;
      a.resize(a.size() + b);
      for (int k = b; k--; ) {
        int64_t m = min(min(req, mx - 1), (d * (c - b) - l * (b - k + 1) - s) / (c - k + 1));
        mx = m;
        if (req && !(k && m) || m < 0) break;
        a.end()[k - b] = l + m;
        s += l + m;
        req -= m;
        if (!k) ok = 1;
      }
      if (ok) { l += d, c -= b, ++k; break; }
      else a.resize(a.size() - b);
    }
    if (!ok) break;
  }
  for (int i = 0; i < c; ++i) a.push_back(a.back() + 1);
  cout << a.size() << '\n';
  for (auto& a: a) cout << a << ' ';
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 22ms
memory: 9212kb

input:

4

output:

446000
100000000000 100000442268 100000896866 100001309890 100001793744 100002177428 100002690634 100003044882 100003587536 100003912252 100004484450 100004779538 100005381376 100005646740 100006278314 100006513858 100007175264 100007380892 100008072226 100008247842 100008969200 100009114708 1000098...

result:

ok n=446000, max_a=999956632604, max_num=152482 >= 4

Test #2:

score: 0
Accepted
time: 21ms
memory: 8104kb

input:

100000

output:

446000
100000000000 100000442268 100000896866 100001309890 100001793744 100002177428 100002690634 100003044882 100003587536 100003912252 100004484450 100004779538 100005381376 100005646740 100006278314 100006513858 100007175264 100007380892 100008072226 100008247842 100008969200 100009114708 1000098...

result:

ok n=446000, max_a=999956632604, max_num=152482 >= 100000

Extra Test:

score: 0
Extra Test Passed