結果

問題 No.339 何人が回答したのか
ユーザー nak3
提出日時 2017-03-11 15:08:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 1,211 ms
コンパイル使用メモリ 162,540 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 12:06:18
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int n;
	cin >> n;
	int a[n];
	int b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a+n);
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (a[i]%a[0]==0||a[0]!=1) {
			b[i] = a[i]/a[0];
		} else {
			ok = false;
			break;
		}
	}

	int ret = 0;
	if (ok) {
		ret = accumulate(b,b+n,0);
	} else {
		ret = accumulate(a,a+n,0);
	}

	cout << ret << endl;

}
0