QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#421260 | #6823. Coffee Overdose | kjhhjki | WA | 15ms | 3668kb | C++20 | 1.1kb | 2024-05-25 15:59:53 | 2024-05-25 15:59:54 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i, a, b) for(i32 i = (a), endi = (b); i <= endi; ++i)
#define foR(i, a, b) for(i32 i = (a), endi = (b); i >= endi; --i)
using namespace std;
template<typename T, typename U>
void chkmin(T &a, U b) { if(a > b) a = b; }
using i32 = int;
using i64 = long long;
using f64 = long double;
int mp[128];
void init()
{
For(i, '0', '9') mp[i] = i - '0';
For(i, 'a', 'z') mp[i] = i - 'a' + 10;
}
void solve()
{
i32 c, s;
cin >> s >> c;
auto check = [s, c](i32 t)
{
i64 res = (s + s - t + 2ll) * (t-1) / 2;
i64 tmp = 0;
i32 a = s - t + 1, d = c + 1, k = a / d + 1;
// cout << a << ' ' << d << ' ' << k << '\n';
tmp = 1ll * (a + (a % d)) * (k) / 2;
return res + tmp * c;
};
i32 res = *std::ranges::partition_point(ranges::iota_view(0, s+1),
[&](i32 t)
{
return check(t) < check(t+1);
});
cout << check(res) << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
init();
i32 T = 1;
cin >> T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
4 1 2 2 1 10 4 172800 172800
output:
2 3 63 29859840000
result:
ok 4 tokens
Test #2:
score: -100
Wrong Answer
time: 15ms
memory: 3604kb
input:
100000 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 ...
output:
1 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 176...
result:
wrong answer 3rd words differ - expected: '3', found: '4'