結果

問題 No.693 square1001 and Permutation 2
ユーザー Imperi_NightImperi_Night
提出日時 2018-08-14 02:14:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 287 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 42,736 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 16:56:36
合計ジャッジ時間 780 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d", &N);
      |         ~~~~~^~~~~~~~~~
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%d", &a[i]);
      |                 ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int N;
	int sum = 0;
	scanf("%d", &N);
	vector <int> a(N);
	for (int i = 0; i<N; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	sum = abs(sum - (N*(N + 1) / 2));
	printf("%d\n", sum);
	return 0;
}
0