結果
| 問題 |
No.406 鴨等間隔の法則
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-14 16:22:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 655 bytes |
| コンパイル時間 | 486 ms |
| コンパイル使用メモリ | 27,904 KB |
| 実行使用メモリ | 14,776 KB |
| 最終ジャッジ日時 | 2025-03-14 16:22:09 |
| 合計ジャッジ時間 | 8,507 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 2 -- * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%ld",&val);
| ~~~~~^~~~~~~~~~~~
main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%ld",&num[i]);
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(){
// 入力されたカモの数
long val = 0;
scanf("%ld",&val);
// 入力されたカモの座標
long num[val];
for(int i = 0;i < val;i ++){
scanf("%ld",&num[i]);
}
// ソート(昇順)
for(long i = 0;i < val;i ++){
for(long j = 0;j < val;j ++){
if(num[i] < num[j]){
long tmp = num[i];
num[i] = num[j];
num[j] = tmp;
}
}
}
long interval = num[1] - num[0];
if(interval == 0){
printf("NO");
return 0;
}
for(long i = 1;i < val - 1;i ++){
if(interval != num[i + 1] - num[i]){
printf("NO");
return 0;
}else{
interval = num[i + 1] - num[i];
}
}
printf("YES");
}
sasa