Educational Codeforces Round 85 (Rated for Div. 2)

Educational Codeforces Round 85 (Rated for Div. 2)_第1张图片
开幕雷击,去世现场
A

#include 
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=1e2+10;
int n,c[maxn],p[maxn];
void solve()
{
	rd(n);
	for(int i=1;i<=n;i++) rd(p[i]),rd(c[i]);
	for(int i=1;i<=n;i++)
	{
		if(p[i]<p[i-1]||c[i]<c[i-1]||p[i]<c[i]||c[i]-c[i-1]>p[i]-p[i-1])
		{
			puts("NO");
			return;
		}
	}
	puts("YES");
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("stdin.in","r",stdin);
	//freopen("stdout.out","w",stdout);
	#endif

	ll T;
    rd(T);
    while(T--)

	solve();
    return 0;
}

B

#include 
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=1e5+10;
ll n,x,a[maxn];
void solve()
{
	ll sum=0,fin=0;
	rd(n),rd(x);
	for(ll i=1;i<=n;i++) rd(a[i]),sum+=a[i];
	sort(a+1,a+1+n);
	ll p=0;
	for(ll i=n;i>=1;i--)
	{
		if(sum/i>=x)
		{
			fin=i;
			break;
		}
		sum-=a[++p];
	}
	cout<<fin<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("stdin.in","r",stdin);
	//freopen("stdout.out","w",stdout);
	#endif

	ll T;
    rd(T);
    while(T--)

	solve();
    return 0;
}

C

#include 
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=300000+10;
ll n,a[maxn],b[maxn],c[maxn],temp,ans;
void solve()
{
	rd(n);
	for(ll i=1;i<=n;i++) rd(a[i]),rd(b[i]);
	for(ll i=2;i<=n;i++) c[i]=max(a[i]-b[i-1],0LL);
	c[1]=max(a[1]-b[n],0LL);
	temp=a[1];
	for(ll i=2;i<=n;i++) temp+=c[i];
	ans=temp;
	for(ll i=2;i<=n;i++)
	{
		temp-=(a[i-1]-c[i-1]+c[i]-a[i]);
		ans=min(ans,temp);
	}
	printf("%lld\n",ans);
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("stdin.in","r",stdin);
	//freopen("stdout.out","w",stdout);
	#endif

	ll T;
    rd(T);
    while(T--)

	solve();
    return 0;
}

D

#include 
using namespace std;
typedef long long ll;
typedef pair<long long,long long> pll;
template<class T>inline void rd(T &x){x=0;char o,f=1;while(o=getchar(),o<48)if(o==45)f=-f;do x=(x<<3)+(x<<1)+(o^48);while(o=getchar(),o>47);x*=f;}
const int inf=~0u>>2; //1073741823
const ll INF=~0ull>>2;//4611686018427387903
const int maxn=300000+10;
ll n,l,r,x,y,i;
void solve()
{
	rd(n),rd(l),rd(r);
	bool flag=l%2;
	x=i=1,y=2;
	while(i+2*(n-x)<l) i+=2*(n-x++);
	y=(l-i)/2+x+1;
	if(y>n) x=1;
	for(ll j=l;j<=r;j++)
	{
		if(flag) printf("%lld ",x);
		else
		{
			printf("%lld ",y++);
			if(y>n)
			{
				x++;
				y=x+1;
				if(x==n) x=1;
			}
		}
		flag=1-flag;
	}
	puts("");

}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("stdin.in","r",stdin);
	//freopen("stdout.out","w",stdout);
	#endif

	ll T;
    rd(T);
    while(T--)

	solve();
    return 0;
}

你可能感兴趣的:(补题,everyday,contest)