結果
| 問題 |
No.716 距離
|
| コンテスト | |
| ユーザー |
Imperi_Night
|
| 提出日時 | 2018-08-17 00:03:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 406 bytes |
| コンパイル時間 | 511 ms |
| コンパイル使用メモリ | 56,892 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-05 01:18:59 |
| 合計ジャッジ時間 | 1,736 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:15:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | for (int i = 0; i < N; i++)scanf("%d", &a[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
int N;
scanf("%d", &N);
vector<int> a(N);
vector<int> b(N - 1);
for (int i = 0; i < N; i++)scanf("%d", &a[i]);
for (int i = 0; i < N - 1; i++)b[i] = a[i + 1] - a[i];
sort(b.begin(), b.end());
int x = a[N - 1] - a[0];
printf("%d\n", b[0]);
printf("%d\n", x);
return 0;
}
Imperi_Night