QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#319152#7750. Revenge on My BossDjangle162857WA 1ms5580kbC++141.4kb2024-02-01 23:52:382024-02-01 23:52:38

Judging History

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

  • [2024-02-01 23:52:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5580kb
  • [2024-02-01 23:52:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " == " << x << endl
#define el '\n'
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
const int inf = 2147483647;
const int N = 100020;
ll a[N], b[N], c[N], n;
ll B;
struct Data {
	ll d;
	ld e;
	int id;
} d[N];
vector<int> check(ll p) {
	ll sum = 0;
	vector<int> ans;
	ans.resize(n + 1);
	for (int i = 1; i <= n; i++) {
		d[i].d = a[i] - b[i];
		sum += d[i].d;
		d[i].e = p * 1.0 / c[i] + B - a[i];
		d[i].id = i;
	}
	sort(d + 1, d + n + 1, [&](const Data &x, const Data &y) {
		if (x.d < 0 && y.d < 0)
			return x.e > y.e;
		if (x.d < 0 || y.d < 0)
			return x.d < y.d;
		return x.d + x.e < y.d + y.e;
	});
	sum = 0;
	ll mx=0;
	for (int i = 1; i <= n; i++) {
		ans[i] = d[i].id;
		if (d[i].e < sum) {
			ans[0] = -1;
			break;
		}
		sum += d[i].d;
	}
	return ans;
}
void solve() {
	cin >> n;
	B = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i] >> c[i];
		B += b[i];
	}
	ll l = 1, r = 1e18;
	vector<int> now;
	while (l < r) {
		ll mid = (l + r) >> 1;
		now = check(mid);
		if (now[0] != -1)
			r = mid;
		else
			l = mid + 1;
	}
	now = check(r);
	for (int i = 1; i <= n; i++) {
		cout << now[i] << " ";
	}
	cout << el;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

详细

Test #1:

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

input:

2
4
1 1 4
5 1 5
1 9 1
9 8 1
9
3 1 4
1 5 9
2 6 5
3 5 8
9 7 9
3 2 3
8 4 6
2 6 8
3 2 7

output:

3 4 2 1 
2 3 8 4 5 7 9 6 1 

result:

wrong answer Wrong Answer on Case#1