求助|为什么过不了
查看原帖
求助|为什么过不了
1048327
KANO07楼主2023/11/10 10:59
int main(){
    int n;
    cin>>n;
    int q=0,p=0;
    int pre,cur;
    cin>>pre;
    for(int i = 1;i<n;i++){
        cin>>cur;
        int tmp = cur-pre;
        if(tmp<0) q-=tmp;
        else p+=tmp;
        pre=cur;
    }
    cout<<max(p,q)<<endl<<1+abs(p-q);
    return 0;
}
2023/11/10 10:59
加载中...