社区讨论

满江红

P1020[NOIP 1999 提高组] 导弹拦截参与者 2已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@lydpwtf0
此快照首次捕获于
2024/07/09 09:13
2 年前
此快照最后确认于
2024/07/09 10:41
2 年前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;

int main(){
    int arr[100000];
    int s=0;
    while(cin>>arr[s]){
        s++;
    }
    int temp[100000]={0},tep=0,tmp[100000]={0},cnt=0;
    for(int i=0;i<s;i++){
        if(i==0){
            temp[tep]=arr[i];
            tmp[cnt]=arr[i];
            tep++;
            cnt++;
        }else{
            if(temp[tep-1]<=arr[i]){
                temp[tep]=arr[i];
                tep++;
            }else if(temp[tep-1]>arr[i]){
                temp[tep-1]=arr[i];
            }
            if(tmp[cnt-1]<=arr[i]){
                for(int j=cnt-1;j>=0;j--){
                    if(tmp[j]>arr[i]){
                        tmp[j+1]=arr[i];
                        break;
                    }
                }
            }else if(tmp[cnt-1]>arr[i]){
                tmp[cnt]=arr[i];
                cnt++;
            }
        }
    }
    cout<<cnt<<endl<<tep;
    return 0;
}

回复

1 条回复,欢迎继续交流。

正在加载回复...