QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#533885#3960. F1 RacingYarema#WA 0ms3680kbC++201.0kb2024-08-26 15:58:582024-08-26 15:59:00

Judging History

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

  • [2024-08-26 15:59:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3680kb
  • [2024-08-26 15:58:58]
  • 提交

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'