QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#533885 | #3960. F1 Racing | Yarema# | WA | 0ms | 3680kb | C++20 | 1.0kb | 2024-08-26 15:58:58 | 2024-08-26 15:59:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
LL f(LL n, LL b, LL x, LL p)
{
LL r = n / x;
int bg = n % x;
int sm = n - bg;
LL res = sm * (r * (r - 1)) / 2 + bg * (r * (r + 1)) / 2;
//cerr << x << ' ' << res << '\n';
return res + (x - 1) * p;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
LL n, p, R, b;
cin >> n >> p >> R >> b;
LL ans = (n - 1) * n / 2 * b;
int l = 1, r = n;
while (l + 4 < r)
{
int ml = l + (r - l) / 3;
int mr = r - (r - l) / 3;
if (f(n, b, ml, p) < f(n, b, mr, p))
r = mr;
else
l = ml;
}
FOR (i, l, r + 1)
ans = min(ans, f(n, b, i, p));
cout << ans + R * n << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
10 10 100 2
output:
1044
result:
ok single line: '1044'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3680kb
input:
122 505 64 3
output:
17869
result:
wrong answer 1st lines differ - expected: '13847', found: '17869'