11.13 解题报告

T1

考场用时:\(1\) h
期望得分:\(100\) pts
实际得分:\(10\) pts
考场写了一个 \(n\log n\) 的贪心,假了,只有 \(10\) 分,然后文件名写错,导致这 \(10\) 分也没有
正解是考虑先按照力量值排序,算出最小初始力量值 \(ans1\),然后让初始力量值为 \(ans1\),按照前面的顺序遍历数组,
如果当前力量值足以穿上当前装备,就入堆,堆中按照 \(b\) 单减为第一关键字,\(d\) 单增为第二关键字排序,按照和力量值同样的方法统计答案。

由于数组没有重排,所以是正确的。

#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

考场用时:\(20\) min
期望得分:\(25\) pts
实际得分:\(15\) pts

posted @ 2022-11-13 23:03  wapmhac  阅读(27)  评论(2编辑  收藏  举报