Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
125086 zhangyang 排队 C++ 通过 100 0 MS 260 KB 362 2024-01-23 16:24:30

Tests(10/10):


#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++; } } if(two)ans+=one; cout<<ans; return 0; }


测评信息: