Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
947 yy033 最近距离 C++ 通过 35 MS 1048 KB 559 2022-05-28 09:41:57

Tests(20/20):


#include<iostream> #include<cstring> #include<cstdio> #include<cstdlib> #include<math.h> #include<string> #include<algorithm> using namespace std; main() { long long n,x=2000001,y=2000001,a[200001]; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) { for(int j=i;j<=n;j++) { if(a[j]==0) { y=abs(i-j); break; } } for(int j=i;j>0;j--) { if(a[j]==0) { x=abs(i-j); break; } } if(x>y) cout<<y<<' '; else cout<<x<<' '; x=2000001; y=2000001; } }


测评信息: