結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2025-03-17 14:07:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 604 bytes |
コンパイル時間 | 497 ms |
コンパイル使用メモリ | 28,288 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-17 14:07:45 |
合計ジャッジ時間 | 2,223 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 21 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long int’ [-Wformat=] 26 | scanf("%d ",loc[i]); | ~^ ~~~~~~ | | | | int* long int main.cpp:4:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 4 | scanf("%ld",&val); | ~~~~~^~~~~~~~~~~~ main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%ld",&loc[i]); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:26:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d ",loc[i]); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void){ long val = 0; scanf("%ld",&val); long loc[val]; for(long i = 0;i < val;i ++){ scanf("%ld",&loc[i]); } for(long i = 0;i < val;i ++){ for(long j = 0;j < val;j ++){ if(loc[i] == loc[j]){ printf("NO"); return 0; } if(loc[i] < loc[j]){ int tmp = loc[i]; loc[i] = loc[j]; loc[j] = tmp; } } } for(int i = 0;i < val;i ++){ scanf("%d ",loc[i]); } printf("\n"); long interval = loc[1] - loc[0]; for(int i = 2;i < val;i ++){ if(interval != (loc[i] - loc[i - 1])){ printf("NO"); return 0; } } printf("YES"); }