QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#628844#7750. Revenge on My BosslixpWA 388ms8356kbC++141.5kb2024-10-10 22:41:112024-10-10 22:41:15

Judging History

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

  • [2024-10-10 22:41:15]
  • 评测
  • 测评结果:WA
  • 用时:388ms
  • 内存:8356kb
  • [2024-10-10 22:41:11]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std ;

const int N = 1e5+10;
long long sumb, summi[N];
int n;

struct Node{
	long long a, b, c, id;
	long long minus, con;
}a[N];

bool cmp(Node a, Node b){
	if(a.minus <= 0 && b.minus <= 0)
		return a.con > b.con;
	if(a.minus <= 0 || b.minus <= 0)
		return a.minus < b.minus;
	return a.con + a.minus < b.con + b.minus; 
}

bool judge(long long x){
	for(int i = 1 ; i <= n ; i++){
		a[i].con = sumb - a[i].a + x / a[i].c;
	}
	sort(a+1, a+n+1, cmp);
	
	long long summi = 0, maxx = 0;
	for(int i = 1 ; i <= n ; i++){
		summi += a[i].minus;
		long long temp = 1ll * a[i].c * (sumb + summi + a[i].b);
		if(temp > maxx)
			maxx = temp;
	} 
	return maxx <= x;
}

void solve(){
	memset(a, 0, sizeof(a));
	sumb = 0;
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i++){
	//	cin >> a[i].a >> a[i].b >> a[i].c;
		scanf("%d%d%d",&a[i].a,&a[i].b,&a[i].c);
		a[i].id = i;
		
		sumb += a[i].b ;
		a[i].minus = a[i].a - a[i].b;
	}
	
	
	long long l = 0, r = 1e18;
    while (l + 1 < r) {
        long long mid = (l+r)>>1;
        if (judge(mid))
            r = mid;
        else
            l = mid;
    }
	judge(r);
	if(n>=100 ) cout<<r<<"  ";
	for(int i = 1 ; i <= n ; i++){
		cout << a[i].id << " ";
	}
	cout << endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T; scanf("%d",&T);
	while(T--){
		solve();
	}
	return 0;
} 

詳細信息

Test #1:

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

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: 388ms
memory: 8356kb

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:

50052759513  70717 6151 48237 28851 35679 19561 94252 73342 13089 34865 69194 82763 50242 22597 3745 24913 97923 53671 77581 47428 82224 93567 61401 50007 4886 54152 28731 91278 99937 6691 26840 6048 46204 66044 60735 44469 20513 45842 18701 46818 27203 9261 50507 8020 72391 54368 86201 18839 64763 ...

result:

wrong output format Expected int32, but "50052759513" found