結果
問題 | No.2335 Jump |
ユーザー | momo |
提出日時 | 2023-06-02 22:19:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 358 bytes |
コンパイル時間 | 1,071 ms |
コンパイル使用メモリ | 80,048 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-28 19:02:33 |
合計ジャッジ時間 | 2,185 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int &v : a) cin >> v; a.push_back(0); sort(a.begin(), a.end()); long long int ans = 0; for (int i = a.size() - 1; i > 0; i--) { ans += a[i] - a[i - 1] - 1; } cout << ans << '\n'; }