結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー |
![]() |
提出日時 | 2017-06-27 20:29:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 21 ms / 5,000 ms |
コード長 | 414 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 36,844 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-04 13:36:15 |
合計ジャッジ時間 | 1,670 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 6 | main(){ | ^~~~ main.cpp: In function ‘int main()’: main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&X[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<stdlib.h> #include<algorithm> using namespace std; int X[100000]; main(){ int N; scanf("%d",&N); for(int i = 0;i < N;i++){ scanf("%d",&X[i]); } sort(X,X+N); int min = 1000000000; for(int i = 0;i < N-1;i++){ int dif = abs(X[i+1]-X[i]); if(dif && dif < min){min = dif;} } if(min == 1000000000){min = 0;} printf("%d\n",min); }