Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
124977 | zhangyang | 排队 | C++ | 解答错误 | 90 | 0 MS | 264 KB | 355 | 2024-01-23 16:15:26 |
#include<iostream> using namespace std; int n,a[40000],ans; signed main(){ cin>>n; int two=0,one=0; for(int i=1;i<=n;i++){ cin>>a[i]; if(a[i]==1){ one++; if(two&&one>two){ ans+=two; two=0; one=0; } }else if(a[i]==2){ if(two==0){ one=0; } two++; } } ans+=one; cout<<ans; return 0; }