补题|Educational Codeforces Round 85 (Rated for Div. 2)

补题|Educational Codeforces Round 85 (Rated for Div. 2)
文章图片

开幕雷击,去世现场
A

#include using namespace std; typedef long long ll; typedef pair pll; templateinline 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]-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 pll; templateinline 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<

C
#include using namespace std; typedef long long ll; typedef pair pll; templateinline 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; }

【补题|Educational Codeforces Round 85 (Rated for Div. 2)】D
#include using namespace std; typedef long long ll; typedef pair pll; templateinline 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)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; }

    推荐阅读