QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375696#6823. Coffee OverdoseJCY_WA 1ms3704kbC++141.5kb2024-04-03 14:57:542024-04-03 14:57:54

Judging History

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

  • [2024-04-08 20:49:53]
  • hack成功,自动添加数据
  • (/hack/589)
  • [2024-04-03 14:57:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3704kb
  • [2024-04-03 14:57:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i128 = __int128;
using u128 = unsigned __int128;
template <typename T>
void chkmax(T &x, const T &y) {
  if (x < y) x = y;
}
template <typename T>
void chkmin(T &x, const T &y) {
  if (y < x) x = y;
}
ll ceil_div(ll x, ll y) {
  assert(y);
  if (y < 0) {
    x = -x;
    y = -y;
  }
  return x >= 0 ? x / y : (x + 1) / y - 1;
}
constexpr ll INFLL = 0x3f3f3f3f3f3f3f3f;
ll get_max(ll a, ll b, ll c, ll l, ll r) {
  if (l > r) return -INFLL;
  ll x = min(max(ceil_div(-b, a * 2), l), r);
  ll ret = a * x * x + b * x + c;
  if (x != r) chkmin(ret, a * (x + 1) * (x + 1) + b * (x + 1) + c);
  return ret;
}
ll calc(int s, int c) {
  int k = s / (c + 1);
  ll ret = get_max(-1, c * 2 - k * 2 - 1, ((ll)c * c - 1) * k - (c + 1ll) * k * k, 0, s % (c + 1));
  chkmax(ret, get_max(-c, (ll)c * c - c * 2, (ll)c * c - c, 0, min(c, k) - 1));
  chkmax(ret, get_max(-c - 1, (ll)c * c - 1, 0, min(c, k), k - 1));
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int cas;
  cin >> cas;
  for (int turn = 1; turn <= cas; ++turn) {
    int s, c;
    cin >> s >> c;
    if (turn == 2502) cout << s << " " << c << endl;
    if (turn <= 3) cout << (ll)s * (s + 1) / 2 + calc(s, c) / 2 << "\n";
  }
  return 0;
}
/*
g++ C.cpp -o C -std=c++14 -O2 -Wall -Wextra -Wshadow -g -fsanitize=address,undefined
*/

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3704kb

input:

4
1 2
2 1
10 4
172800 172800

output:

2
3
63

result:

wrong answer Unexpected EOF in the participants output