QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#256333#7750. Revenge on My Bossucup-team346WA 632ms9916kbC++202.1kb2023-11-18 18:35:582023-11-18 18:35:59

Judging History

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

  • [2023-11-18 18:35:59]
  • 评测
  • 测评结果:WA
  • 用时:632ms
  • 内存:9916kb
  • [2023-11-18 18:35:58]
  • 提交

answer

#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define db double
#define ve vector<int>
#define pa pair<int,int>
#define fr first
#define sd second
#define pb push_back
#define mp make_pair
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
inline ll read()
{
	char ch = getchar();
	ll s = 0, w = 1;
	while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
	return s * w;
}
#define N 100010
#define int ll
int n, m;
int a[N], b[N], c[N];
int A[N], B[N];
int sb[N];
int p[N];
bool cmp1(int x, int y) {return B[x] - A[x]> B[y] - A[y];}
bool cmp2(int x, int y) {return B[x] < B[y];}
int check(int W)
{
	for (int i = 1; i <= n; i ++)
	{
		A[i] = a[i] - b[i];
		B[i] = W / c[i] - sb[n] + a[i];
	}
	vector<int>P, Q, R;

			for (int i = 1; i <= n; i ++)if (A[i] < 0)P.push_back(i); else if (A[i] > 0)Q.push_back(i); else R.push_back(i);
	sort(P.begin(), P.end(), cmp1); sort(Q.begin(), Q.end(), cmp2);
	int tot = 0;
	for (int x : P)p[++ tot] = x; for (int x : R)p[++ tot] = x; for (int x : Q)p[++ tot] = x;
	int sum = 0;
	// cout << "??:" << W << endl;
	// for (int i = 1; i <= n; i ++)cout << A[i] << ' '; cout << endl;
	// for (int i = 1; i <= n; i ++)cout << B[i] << ' '; cout << endl;
	for (int i = 1; i <= n; i ++)
	{
		if (sum > B[p[i]])return 0;
		sum += A[p[i]];
	}
	return 1;
}
void sol()
{
	cin >> n;
	for (int i = 1; i <= n; i ++)cin >> a[i] >> b[i] >> c[i];
	for (int i = 1; i <= n; i ++)sb[i] = sb[i - 1] + b[i];
	// check(80);
	int l = 0, r = 1e18, ans = 1e18;
	while (l <= r)
	{
		int mid = (l + r) >> 1;
		if (check(mid))ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	check(ans);
	// cout << ans << endl;
	for (int i = 1; i <= n; i ++)
	{
		cout << p[i];
		if (i == n)cout << '\n';
		else cout << ' ';
	}
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T; cin >> T;
	while (T --)sol();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 7588kb

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

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 632ms
memory: 9916kb

input:

1
100000
581297 102863 1
742857 42686 1
676710 233271 1
443055 491162 1
442056 28240 1
769277 331752 1
8608 369730 1
495112 525554 1
787449 938154 1
441186 850694 1
84267 925450 1
740811 32385 1
834021 37680 1
257878 564126 1
90618 914340 1
239641 463103 1
40687 343062 1
587737 458554 1
103684 48666...

output:

34165 58976 76404 97462 81944 63569 22053 24693 82043 7559 68501 35301 39883 11448 91985 42218 73062 38913 60104 61747 17135 39691 48773 76455 53224 928 82878 21243 40729 2119 98834 26666 1844 44145 94650 67247 78710 92428 758 81020 70922 1714 62638 25132 88997 54154 80672 33568 69608 44151 77582 41...

result:

wrong answer Wrong Answer on Case#1