QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#267971 | #7750. Revenge on My Boss | qkm66666 | WA | 1ms | 5684kb | C++17 | 1.9kb | 2023-11-27 21:57:12 | 2023-11-27 21:57:12 |
Judging History
answer
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<vector>
#include<bitset>
#include<random>
#include<ctime>
#include<queue>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define FF fflush(stdout)
#define inf 0x3f3f3f3f
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
int s=0,f=1;
char x=getchar();
while(!isdigit(x))f=(x=='-'?-1:1),x=getchar();
while(isdigit(x))s=s*10+x-'0',x=getchar();
return s*f;
}
const int p=1e9+7;
//ll ksm(int a,int b){ll ans=1,bs=a;while(b){if(b&1)ans=ans*bs%p;bs=bs*bs%p;b>>=1;}return ans;}
mt19937 rd(time(0));
#define reaD read
ll a[100005],b[100005],c[100005];
int n;
ll pre[100005];
ll s;
vector<pii> d;
bool ck(ll x)
{
for(int i=1;i<=n;i++)
pre[i]=x/c[i]-s-b[i];
ll del=0;
d.clear();
for(int i=1;i<=n;i++)
if(a[i]<=b[i])del+=a[i]-b[i];
else d.pb(mp(a[i]-b[i]+pre[i],i));
sort(d.begin(),d.end());
for(auto j:d)
{
if(del>pre[j.se])return 0;
del+=a[j.se]-b[j.se];
}
return 1;
}
int main()
{
int T=reaD();
while(T--)
{
n=reaD();s=0;
for(int i=1;i<=n;i++)
a[i]=read(),b[i]=read(),c[i]=reaD(),s+=b[i];
ll l=1,r=1e18;
while(l<=r)
{
ll mid=(l+r)>>1;
if(ck(mid))r=mid-1;
else l=mid+1;
}
ck(l);
for(int i=1;i<=n;i++)
if(a[i]<=b[i])printf("%d ",i);
for(auto j:d)printf("%d ",j.se);
puts("");
}
// system("pause");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5684kb
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:
1 3 2 4 2 3 4 8 5 9 7 1 6
result:
wrong answer Wrong Answer on Case#2