为啥re
查看原帖
为啥re
988978
yhb_luogu楼主2025/7/29 09:18
#include <bits/stdc++.h>
using namespace std;
int d[1000005];
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
		cin>>d[i];
    }
    int st=1;
    int day=0;
    while(1){
        while(d[st]==0) st++;
        if(st>n) break;
        day++;
        int e=n;
        for(int i=st;i<=n;i++){
            if(d[i]==0){
                e=i-1;
                break;
            }
        }
        for(int i=st;i<=e;i++){
            d[i]--;
        }
    }
    cout<<day;
    return 0;
}

这样就re

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
int d[1000005];
    cin>>n;
    for(int i=1;i<=n;i++){
		cin>>d[i];
    }
    int st=1;
    int day=0;
    while(1){
        while(d[st]==0) st++;
        if(st>n) break;
        day++;
        int e=n;
        for(int i=st;i<=n;i++){
            if(d[i]==0){
                e=i-1;
                break;
            }
        }
        for(int i=st;i<=e;i++){
            d[i]--;
        }
    }
    cout<<day;
    return 0;
}

这样就没事了

2025/7/29 09:18
加载中...