結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
FVRChan
|
| 提出日時 | 2017-09-29 09:06:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 5,000 ms |
| コード長 | 382 bytes |
| コンパイル時間 | 638 ms |
| コンパイル使用メモリ | 68,280 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-15 19:45:52 |
| 合計ジャッジ時間 | 1,543 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | int n;scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:12:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | for(int i=0;i<n;i++)scanf("%d",&x[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<iostream>
#include<queue>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
int n;scanf("%d",&n);
int *x=new int[n];
int mv=999999999;
for(int i=0;i<n;i++)scanf("%d",&x[i]);
sort(x,x+n);
for(int i=0;i<n-1;i++){
if(x[i] != x[i+1]){
mv=min(abs(x[i]-x[i+1]),mv);
}
}if(mv==999999999)mv=0;
cout<<mv<<endl;
}
FVRChan