結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
stone_725
|
| 提出日時 | 2015-09-06 00:28:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 459 bytes |
| コンパイル時間 | 480 ms |
| コンパイル使用メモリ | 47,684 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2025-01-03 07:36:47 |
| 合計ジャッジ時間 | 1,756 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d", &num);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
int main(){
int n;
scanf("%d", &n);
set<int> s;
for(int i = 0; i < n; i++){
int num;
scanf("%d", &num);
s.insert(num);
}
int before = *s.begin(), ans = 1 << 29;
if(s.size() == 0){
ans = 0;
}
else{
for(auto it = s.begin(); ++it != s.end();){
ans = min(ans, *it - before);
before = *it;
}
}
printf("%d\n", ans);
return 0;
}
stone_725