QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#252083#7750. Revenge on My Bossucup-team1453#WA 1ms7712kbC++111.8kb2023-11-15 15:30:372023-11-15 15:30:37

Judging History

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

  • [2023-11-15 15:30:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7712kb
  • [2023-11-15 15:30:37]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define vi vector <int>
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
#define uint unsig7ned int
#define ull unsigned long long 
#define i128 __int128
using namespace std;
const int N = 1e6 + 7;
int n;
ll a[N], b[N], c[N];
bool check(vector < pair < ll, ll > > vc) {
	sort(vc.begin(), vc.end());
	ll sum = 0;
	for(auto&p : vc) {
		sum += p.second;
		if(sum > p.first) 
			return 0;
	}
	return 1;
}
void Main() {
	cin >> n;
	L(i, 1, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	ll l = 0, r = 1e18, ans = -1;
	while(l <= r) {
		ll mid = (l + r) >> 1;
		ll suma = 0, sumb = 0;
		L(i, 1, n) {
			suma += a[i], sumb += b[i];
		}
		vector < pair < ll, ll > > A, B;
		L(i, 1, n) {
			if(a[i] <= b[i]) {
				A.emplace_back(sumb - b[i] - (mid / c[i]), b[i] - a[i]);
			}
		}
		L(i, 1, n) {
			if(a[i] > b[i]) {
				B.emplace_back(suma - a[i] - (mid / c[i]), a[i] - b[i]);
			}
		}
		if(check(A) && check(B)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	ll suma = 0, sumb = 0;
	L(i, 1, n) {
		suma += a[i], sumb += b[i];
	}
	vector < pair < ll, ll > > A, B;
	L(i, 1, n) {
		if(a[i] <= b[i]) {
			A.emplace_back(sumb - b[i] - (ans / c[i]), i);
		}
	}
	L(i, 1, n) {
		if(a[i] > b[i]) {
			B.emplace_back(suma - a[i] - (ans / c[i]), i);
		}
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());
	for(auto&x : A)
		cout << x.second << ' ';
	for(auto&x : B)
		cout << x.second << ' ';
	cout << '\n';
}
int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t; cin >> t; while(t--) Main();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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 1 2 4 
3 8 2 4 9 6 1 7 5 

result:

wrong answer Wrong Answer on Case#2