提出 #14696561
ソースコード 拡げる
Copy
#include <bits/stdc++.h> #define INF 1e9 using namespace std; #define REPR(i,n) for(int i=(n); i >= 0; --i) #define FOR(i, m, n) for(int i = (m); i < (n); ++i) #define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define ALL(a) (a).begin(),(a).end() #define endl "\n" template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } typedef long long ll; void solve() { int N,M; cin >> N >> M; vector<int> vp(M); if (N >= M ) { cout << 0 << endl; return; } REP(i,M) { int x; cin >> x; vp[i] = x; } sort(ALL(vp)); vector<int> vl(M-1); REP(i,M-1) vl[i] = vp[i+ 1] - vp[i]; sort(ALL(vl)); reverse(ALL(vl)); ll sm = 0; FOR(i,N-1,M-1) sm += vl[i]; cout << sm << endl; } int main() { solve(); return 0; }
提出情報
提出日時 | |
---|---|
問題 | C - Streamline |
ユーザ | reud |
言語 | C++ (GCC 9.2.1) |
得点 | 300 |
コード長 | 985 Byte |
結果 | AC |
実行時間 | 41 ms |
メモリ | 4016 KB |
ジャッジ結果
セット名 | All | Sample | ||||
---|---|---|---|---|---|---|
得点 / 配点 | 300 / 300 | 0 / 0 | ||||
結果 |
|
|
セット名 | テストケース |
---|---|
All | 0_normal_1, 0_normal_2, 0_normal_3, 0_normal_4, 1_max_1, 1_max_2, 1_max_3, 1_max_4, 2_nsmall_1, 2_nsmall_2, 2_nsmall_3, 2_nsmall_4, 3_msmall_1, 3_msmall_2, 3_msmall_3, 3_msmall_4, 4_corner_1, 4_corner_2, 4_corner_3, 4_corner_4, sample_01, sample_02, sample_03 |
Sample | sample_01, sample_02, sample_03 |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
0_normal_1 | AC | 10 ms | 3572 KB |
0_normal_2 | AC | 2 ms | 3488 KB |
0_normal_3 | AC | 3 ms | 3376 KB |
0_normal_4 | AC | 40 ms | 3888 KB |
1_max_1 | AC | 2 ms | 3488 KB |
1_max_2 | AC | 2 ms | 3376 KB |
1_max_3 | AC | 3 ms | 3648 KB |
1_max_4 | AC | 41 ms | 4016 KB |
2_nsmall_1 | AC | 37 ms | 3936 KB |
2_nsmall_2 | AC | 18 ms | 3596 KB |
2_nsmall_3 | AC | 37 ms | 3516 KB |
2_nsmall_4 | AC | 19 ms | 3668 KB |
3_msmall_1 | AC | 2 ms | 3480 KB |
3_msmall_2 | AC | 2 ms | 3452 KB |
3_msmall_3 | AC | 2 ms | 3608 KB |
3_msmall_4 | AC | 2 ms | 3456 KB |
4_corner_1 | AC | 11 ms | 3640 KB |
4_corner_2 | AC | 30 ms | 3652 KB |
4_corner_3 | AC | 3 ms | 3488 KB |
4_corner_4 | AC | 3 ms | 3560 KB |
sample_01 | AC | 2 ms | 3508 KB |
sample_02 | AC | 2 ms | 3428 KB |
sample_03 | AC | 3 ms | 3520 KB |