QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#375696 | #6823. Coffee Overdose | JCY_ | WA | 1ms | 3704kb | C++14 | 1.5kb | 2024-04-03 14:57:54 | 2024-04-03 14:57:54 |
Judging History
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