結果

問題 No.929 よくあるボールを移動するやつ
ユーザー mmn15277198mmn15277198
提出日時 2020-03-14 02:51:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 77,768 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-15 11:25:28
合計ジャッジ時間 4,160 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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(){
	int n,count=0;
	cin >> n;
	int a[n];
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	for(int i=0;i<n;i++){
		if(a[i] >= 2){
			for(int j=0;j<n;j++){
				if(a[i]==1)break;
				if(a[j]==0){
					a[j]=1;
					a[i]=a[i]-1;
					count += abs(i-j);
				}
			}
		}
	}
	
	cout << count << endl;
	return 0;
}
0