結果

問題 No.929 よくあるボールを移動するやつ
ユーザー mmn15277198mmn15277198
提出日時 2020-03-14 11:31:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 78,280 KB
実行使用メモリ 4,760 KB
最終ジャッジ日時 2023-08-15 11:41:54
合計ジャッジ時間 8,044 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 16 ms
4,712 KB
testcase_14 AC 17 ms
4,568 KB
testcase_15 AC 17 ms
4,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<iomanip>
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	long n;
	long count=0;
	cin >> n;
	int a[n],b[n],c[n];
	
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i] >= 2){
			for(int j=0;j<n;j++){
				b[j]=a[i];
				c[j]=i;
			}
		}
	}
	
	int j=0;
	for(int i=0;i<n;i++){
		if(a[i] == 0){
			a[i]=1;
			b[j] -= 1;
			count += abs(c[j]-i);
			if(b[j]==1){
				j++;
			}
		}
	}
	
	cout << count << endl;
	return 0;
}
0