QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#258078 | #7750. Revenge on My Boss | ucup-team266# | WA | 0ms | 3636kb | C++20 | 2.1kb | 2023-11-19 14:52:58 | 2023-11-19 14:52:58 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int n;
ll a[100100],b[100100],c[100100];
bool check(ll mid,bool echo=false)
{
// cerr<<mid<<":"<<endl;
ll sum=0;
for(int i=1;i<=n;i++)
sum+=b[i];
vector<pair<pair<ll,ll>,int>> vec;
for(int i=1;i<=n;i++)
{
ll l=mid/c[i];
vec.pb(mp(b[i]-a[i],sum+a[i]-l),i);
// cerr<<b[i]-a[i]<<" "<<sum+a[i]-l<<endl;
}
sort(ALL(vec),[&](pair<pair<ll,ll>,int> a,pair<pair<ll,ll>,int> b)
{
if(a.first.first>=0&&b.first.first<0) return true;
if(a.first.first<0&&b.first.first>=0) return false;
if(a.first.first>=0) return a.first.second+a.first.first>b.second+b.first.first;
return a.first.second+a.first.first>b.second+b.first.first;
});
ll s=0;
for(auto pr:vec)
{
if(echo)
cout<<pr.second<<" ";
if(s<pr.first.second) return false;
s+=pr.first.first;
}
if(echo) cout<<'\n';
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i]>>b[i]>>c[i];
ll l=0,r=1e18;
while(l<r)
{
ll mid=(l+r)/2;
if(check(mid))
r=mid;
else
l=mid+1;
}
// cerr<<l<<endl;
check(l,true);
// if(!t)
// {
// vector<int> vec={3,8,4,2,5,9,7,1,6};
// ll ans=0;
// for(int i=0;i<9;i++)
// {
// ll A=0;
// for(int j=0;j<=i;j++)
// A+=a[j];
// for(int j=i;j<9;j++)
// A+=b[j];
// ans=max(ans,A*c[i]);
// }
// cout<<ans<<endl;
// }
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3636kb
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 1 6 7 9
result:
wrong answer Wrong Answer on Case#2