• Educational Codeforces Round 85 (Rated for Div. 2)


    A

    #include <bits/stdc++.h>
    using namespace std;
    
    #define int long long
    const int N = 1005;
    
    int t,n,p[N],c[N];
    
    signed main() {
        ios::sync_with_stdio(false);
        cin>>t;
        while(t--) {
            cin>>n;
            for(int i=1;i<=n;i++) cin>>p[i]>>c[i];
            int fg=1;
            for(int i=1;i<=n;i++) if(p[i]<p[i-1] || c[i]<c[i-1]) fg=0;
            for(int i=1;i<=n;i++) if(p[i]-p[i-1]<c[i]-c[i-1]) fg=0;
            if(fg) puts("YES");
            else puts("NO");
        }
    }
    

    B

    #include <bits/stdc++.h>
    using namespace std;
    
    #define int long long
    const int N = 100005;
    
    int t,n,x,a[N];
    
    signed main() {
        ios::sync_with_stdio(false);
        cin>>t;
        while(t--) {
            cin>>n>>x;
            for(int i=1;i<=n;i++)cin>>a[i];
            sort(a+1,a+n+1);
            reverse(a+1,a+n+1);
            int s=0,c=0;
            for(int i=1;i<=n;i++) {
                s+=a[i];
                c++;
                if(s<c*x) {
                    c--;
                    break;
                }
            }
            cout<<c<<endl;
        }
    }
    

    C

    #include <bits/stdc++.h>
    using namespace std;
    
    #define int long long
    const int N = 300005;
    
    int t,n,a[N],b[N];
    
    signed main() {
        ios::sync_with_stdio(false);
        cin>>t;
        while(t--) {
            cin>>n;
            for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
            int sum=0;
            a[0]=a[n];b[0]=b[n];
            for(int i=1;i<=n;i++) sum+=max(a[i]-b[i-1],0ll);
            int ans=1e18;
            for(int i=1;i<=n;i++) ans=min(ans,sum+a[i]-max(a[i]-b[i-1],0ll));
            cout<<ans<<endl;
        }
    }
    

    D
    很容易发现按照 1 2 1 3 1 4 2 3 2 4 3 4 1 这样构造即可

    #include <bits/stdc++.h>
    using namespace std;
    
    #define int long long
    int t,n,l,r;
    
    signed main() {
        ios::sync_with_stdio(false);
        cin>>t;
        while(t--) {
            cin>>n>>l>>r;
            int i=1;
            int x=0;
            while(l-x>2*(n-i) && i<=n) {
                x+=2*(n-i);
                i++;
            }
            int j=(l-x+1)/2+i;
            int len=r-l+1;
            if(l%2==0) {
                cout<<j<<" ", --len;
                ++j;
                if(j>n) j=(++i)+1;
            }
            while(len>0) {
                if(i>=n) i=1,j=1;
                cout<<i<<" ";
                if(len>1) cout<<j<<" ";
                ++j;
                if(j>n) j=(++i)+1;
                if(i>=n) i=1,j=1;
                len-=2;
            }
            cout<<endl;
        }
    
    }
    
  • 相关阅读:
    Elasticsearch入门教程
    Elasticsearch环境安装配置
    Elasticsearch教程
    linux下elasticsearch 安装、配置及示例
    Elasticsearch集群部署
    elasticsearch-hadoop使用
    Oracle监控的关键指标
    oracle分区表的使用和查询
    nginx访问控制用户认证两种方式
    nginx创建默认虚拟主机
  • 原文地址:https://www.cnblogs.com/mollnn/p/12686323.html
Copyright © 2020-2023  润新知