結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
Ysmr_Ry
|
| 提出日時 | 2015-01-29 00:25:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 5,000 ms |
| コード長 | 551 bytes |
| コンパイル時間 | 737 ms |
| コンパイル使用メモリ | 51,376 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-03 03:16:13 |
| 合計ジャッジ時間 | 1,699 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf( "%d", &N );
| ~~~~~^~~~~~~~~~~~
main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf( "%d", &X );
| ~~~~~^~~~~~~~~~~~
ソースコード
// yukicoder 135 (http://yukicoder.me/problems/135)
#include<cstdio>
#include<algorithm>
#include<vector>
#define rep(i,a) for(int i=0;i<(a);++i)
#define all(a) (a).begin(), (a).end()
const int MAX_N = 100000;
int N;
std::vector<int> xs;
int main()
{
scanf( "%d", &N );
rep( i, N )
{
int X;
scanf( "%d", &X );
xs.push_back(X);
}
std::sort( all(xs) );
xs.erase( std::unique( all(xs) ), xs.end() );
int ans = 1<<30;
rep( i, xs.size()-1 )
ans = std::min( ans, abs(xs[i+1]-xs[i]) );
printf( "%d\n", ans==1<<30?0:ans );
return 0;
}
Ysmr_Ry