社区讨论

求助awa

P1672[USACO05FEB] Feed Accounting S参与者 3已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@m5z97ori
此快照首次捕获于
2025/01/16 19:35
去年
此快照最后确认于
2025/01/16 20:27
去年
查看原帖
CPP
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
const int maxn=200;
struct node{
	int l,r;
} a[maxn];
int n,t,s,e;
inline bool judge(int x){
	int sum=s-e;
	for(int i=1;i<=n;i++){
		int ks=max(a[i].l,x);
		int js=min(a[i].r,t);
		sum-=(js-ks+1);
	}
	cout<<x<<" "<<sum<<endl;
	if(sum==0) return true;
	else return false;
}
inline int read(){
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
inline void work(){
	n=read(); s=read(); e=read(); t=read();
	for(int i=1;i<=n;i++) a[i].l=read(),a[i].r=read();
	for(int i=t;i>=0;i--){
		if(judge(i)){
			cout<<i;
			break;
		}
	}
}
signed main(){work();return 0;}
flhuang longlong666 Liyanxi1028 wjl1100 little_QL SiriusIV wsy_I

回复

3 条回复,欢迎继续交流。

正在加载回复...