LOADING

加载过慢请开启缓存,浏览器默认开启

Waiting for the dawn

daily 2

2023/7/6

daily codeforces

阅读全文

daily 2

2023/7/5

daily codeforces

阅读全文

daily 2

2023/7/4

CF 1038D

int main(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    bool pos_flag=false,neg_flag=false;
    int minimal=INT_MAX;
    long long ans=0;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        if(n==1){
            cout<<a[1]<<'\n';
            return 0;
        }
        pos_flag|=(a[i]>=0);
        neg_flag|=(a[i]<=0);
        minimal=min(minimal,abs(a[i]));
        ans+=abs(a[i]);
    }
    if(pos_flag&&neg_flag){
        cout<<ans<<'\n';
    }else{
        cout<<ans-2*minimal<<'\n';
    }
    return 0;
}

CF 1133E



阅读全文

daily 2

2023/7/3

daily codeforces

阅读全文

daily 1

2023/7/2

CF 12A

for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            if(a[i][j]!=a[3-i-1][3-j-1])
            {
                cout<<"NO";
                return 0;
            }
    cout<<"YES";
    return 0;
阅读全文

daliy 1

2023/7/1

daily codeforces

阅读全文

daily 2

2023/6/30

daily codeforces

阅读全文

daily 2

2023/6/29

daily codeforces

阅读全文

daily 2

2023/6/28

CF 940E

int main(){
    int n,c;
    cin>>n>>c;
    vector<int>a(n+1);
    ll sum=0;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        sum+=a[i];
    }
    vector<int>Q(n+5);
    int l=1,r=0;
    vector<ll>dp(n+1);
    for(int i=1;i<=n;++i){
        while(l<=r&&a[Q[r]]>=a[i]){
            r--;
        }
        Q[++r]=i;
        while(l<=r&&Q[l]<=i-c)++l;
        if(i>=c){
            dp[i]=max(dp[i-1],dp[i-c]+a[Q[l]]);
        }
    }
    cout<<sum-dp[n]<<'\n';
}

CF 946D

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<string>days(n+1);
    vector<int>cnt(n+1);
    vector<vector<int>>dp(n+1,vector<int>(k+1,INF));
    vector<vector<int>>skip(n+1,vector<int>(m+1,INF));
    for(int i=1;i<=n;++i){
        cin>>days[i];
        days[i]=')'+days[i];
        vector<int>pos(m+1);
        for(int j=1;j<days[i].size();++j){
            if(days[i][j]=='1'){
                pos[++cnt[i]]=j;
            }
        }
        skip[i][cnt[i]]=0;
        for(int len=1;len<=cnt[i];++len){
            for(int l=1;l+len-1<=cnt[i];++l){
                int r=l+len-1;
                skip[i][cnt[i]-len]=min(skip[i][cnt[i]-len],pos[r]-pos[l]+1);//the minimal time you need to stay at schoool if you skip cnt[i]-len class
            }
        }
    }
    for(int i=0;i<=k;++i){
        dp[0][i]=0;
    }
    for(int i=1;i<=n;++i){
        for(int j=0;j<=k;++j){
            for(int sk=0;sk<=min(j,cnt[i]);++sk){
                dp[i][j]=min(dp[i][j],dp[i-1][j-sk]+skip[i][sk]);
            }
        }
    }
    cout<<dp[n][k]<<'\n';
}
阅读全文

daily 2

2023/6/27

daily codeforces

阅读全文
1 ... 15 16 17 18 19 ... 30
avatar
Yanxin Xiang

愿有一天能和你最重要的人再次相逢