結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー |
![]() |
提出日時 | 2015-01-25 23:26:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 23 ms / 5,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 573 ms |
コンパイル使用メモリ | 42,032 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-03 03:02:09 |
合計ジャッジ時間 | 1,676 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:11:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | for( int i = 0 ;i < n; i ++) scanf("%d",&dat[i]); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <algorithm> using namespace std; int dat[100003]; int main(){ int n; scanf("%d",&n); for( int i = 0 ;i < n; i ++) scanf("%d",&dat[i]); sort(dat,dat+n); int ans = 0; for (int i = 0; i + 1 < n; i++) { int cur = dat[i+1] - dat[i]; if (cur == 0) continue; if (ans == 0 || ans > cur) { ans = cur; } } printf("%d\n", ans); }