QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#310813#7750. Revenge on My Boss275307894a#WA 413ms15916kbC++141.6kb2024-01-21 18:21:042024-01-21 18:21:05

Judging History

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

  • [2024-01-21 18:21:05]
  • 评测
  • 测评结果:WA
  • 用时:413ms
  • 内存:15916kb
  • [2024-01-21 18:21:04]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e6+5,M=1.5e7+5,K=(1<<25)+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n,a[N],b[N],c[N];
vector<int> i1,i2,i3;
int id[N],ih;
ll ti[N],sa[N],sb[N];
int CK(ll mid){
	int i;
	sort(i1.begin(),i1.end(),[&](int x,int y){return mid/c[x]-b[x]>mid/c[y]-b[y];});
	sort(i3.begin(),i3.end(),[&](int x,int y){return mid/c[x]-a[x]<mid/c[y]-a[y];});
	ih=0;for(int i:i1) id[++ih]=i;for(int i:i2) id[++ih]=i;for(int i:i3) id[++ih]=i;
	for(int i=1;i<=n;i++) sa[i]=sa[i-1]+a[id[i]];for(int i=n;i;i--) sb[i]=sb[i+1]+b[id[i]];
	ll ans=0;for(int i=1;i<=n;i++) ans=max(ans,c[id[i]]*(sa[i]+sb[i]));
	return ans<=mid;
}
void Solve(){
	int i,j;scanf("%d",&n);
	i1.clear();i2.clear();i3.clear();
	for(i=1;i<=n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		if(a[i]<b[i]) i1.emplace_back(i);
		else if(a[i]==b[i]) i2.emplace_back(i);
		else i3.emplace_back(i);
	} 
	ll l=-1,r=2e17,mid;
	while(l+1<r) mid=l+r>>1,(CK(mid)?r:l)=mid;
	CK(r);
	for(i=1;i<=n;i++) printf("%d%c",id[i]," \n"[i==n]);
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 12176kb

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

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 413ms
memory: 15916kb

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:

32063 35138 77895 37175 1117 78892 13855 93403 57307 43882 10790 40485 75847 86508 16681 30921 37548 74098 71155 60433 22241 74378 28602 30951 65092 98171 260 71472 73404 2098 26268 89359 83373 57 41825 24139 11373 63971 45598 22777 41079 27203 79576 94828 67086 63986 84460 6652 82720 32084 87144 88...

result:

wrong answer Wrong Answer on Case#1