11.13 解题报告
T1
考场用时:
期望得分:
实际得分:
考场写了一个 然后文件名写错,导致这 。
正解是考虑先按照力量值排序,算出最小初始力量值
如果当前力量值足以穿上当前装备,就入堆,堆中按照
由于数组没有重排,所以是正确的。
#include<bits/stdc++.h>
#define ll long long
#define lc(k) k<<1
#define rc(k) k<<1|1
#define orz cout<<"I AK IOI\n"
//#define int long long
const int MAX=2e5+10;
const int MOD=998244353;
using namespace std;
inline char readchar(){
static char buf[100000], *p1 = buf, *p2 = buf;
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
inline int read(){
#define readchar getchar
int res = 0, f = 0;
char ch = readchar();
for(; !isdigit(ch); ch = readchar()) if(ch == '-') f = 1;
for(; isdigit(ch); ch = readchar()) res = (res << 1) + (res << 3) + (ch ^ '0');
return f ? -res : res;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9) write(x/10);
putchar(x%10+'0');
}
struct node{
int a,b,c,d;
friend bool operator < (node x,node y){
if(x.b==y.b) return x.d<y.d;
return x.b>y.b;
}
}a[MAX],b[MAX];
bool cmp(node x,node y){
return x.a<y.a;
}
bool cmp1(node x,node y){
return x.b<y.b;
}
priority_queue<node> q;
#define mk make_pair
void mian(){
int n=read();
memset(a,0,sizeof a);
memset(b,0,sizeof b);
for(int i=1;i<=n;i++){
a[i].a=read();
a[i].b=read();
a[i].c=read();
a[i].d=read();
}
sort(a+1,a+1+n,cmp);
int ans1=0,ans2=0,x=0,y=0;
for(int i=1;i<=n;i++){
ans1=max(ans1,a[i].a-x);
x+=a[i].c;
}
x=ans1;
for(int i=1;i<=n;i++){
while(x<a[i].a){
node f=q.top();q.pop();
x+=f.c;ans2=max(ans2,f.b-y);
y+=f.d;
}
q.push(a[i]);
}
while(!q.empty()){
node f=q.top();q.pop();
ans2=max(ans2,f.b-y);
y+=f.d;
}
cout<<ans1<<" "<<ans2<<'\n';
return ;
}
signed main(){
int T=read();
while(T--) mian();
return 0;
}
T2
考场用时:
期望得分:
实际得分:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库