QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#177063 | #6880. Operation Hope | Nesraychan | AC ✓ | 118ms | 13060kb | C++14 | 1.3kb | 2023-09-12 15:15:13 | 2023-09-12 15:15:14 |
Judging History
answer
#include<bits/stdc++.h>
#define IL inline
#define reg register
#define N 100100
IL int read()
{
reg int x=0; reg char ch=getchar();
while(ch<'0'||ch>'9')ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x;
}
int n,m,a[N][2][3],mx[3];
struct Node
{
int p,c,w;
IL bool operator <(const Node &a)const{return w>a.w;}
};
bool type[N];
int ans=1e9;
IL void cmin(reg int &x,reg int y){x>y?x=y:0;}
IL void cmax(reg int &x,reg int y){x<y?x=y:0;}
IL void work()
{
n=read(),memset(mx,0,sizeof(mx));
for(reg int i=1;i<=n;++i)type[i]=0;
std::priority_queue<Node>q[3];
for(reg int i=1,j,k;i<=n;++i)
{
for(j=0;j<2;++j)for(k=0;k<3;++k)a[i][j][k]=read();
for(j=3;j--;)cmax(mx[j],a[i][0][j]),q[j].push({i,0,a[i][0][j]});
}
ans=1e9;
while(1)
{
reg int id,w=-1,p;
for(reg int o=3,val;o--;)
{
while(!q[o].top().c&&type[q[o].top().p])q[o].pop();
val=mx[o]-q[o].top().w; if(w<val)w=val,id=o;
}
cmin(ans,w); if(type[p=q[id].top().p])break; type[p]=1;
for(reg int o=3;o--;)q[o].push({p,1,a[p][1][o]}),cmax(mx[o],a[p][1][o]);
}
printf("%d\n",ans);
}
main()
{
for(reg int t=read();t--;work());
}
詳細信息
Test #1:
score: 100
Accepted
time: 118ms
memory: 13060kb
input:
99 1000 532114032 55099632 197592060 601440117 964448551 693620489 68503446 149314803 308777541 408078601 977772348 978400861 185066959 236214410 460480442 842502015 709303988 675932475 793016330 161748857 511444978 852914351 281720292 552030608 9982160 15933748 8254470 175080600 567563770 461489051...
output:
982758431 499804923 99919477 99613700 99922111 99914205 99946480 99849310 114469 959350057 499447574 99965775 99807900 99959755 99858165 99900104 99981039 114408 983543586 499348157 99948914 99680790 99821819 99927070 99827404 99854234 114334 984379893 499383664 99973920 99536294 99818752 99826757 9...
result:
ok 99 lines