結果

問題 No.370 道路の掃除
ユーザー 0w10w1
提出日時 2016-11-24 16:05:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 171,060 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 12:55:43
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 2 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 WA -
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
  int N, M; cin >> N >> M;
  vector< int > D( M );
  for( int i = 0; i < M; ++i )
    cin >> D[ i ];
  sort( D.begin(), D.end() );
  int ans = 0x3f3f3f3f;
  for( int i = N - 1; i < M; ++i ){
    if( D[ i - ( N - 1 ) ] * D[ i ] < 0 )
      ans = min( ans, 2 * min( -D[ i - ( N - 1 ) ], D[ i ] ) + max( -D[ i - ( N - 1 ) ], D[ i ] ) );
    else
      ans = min( ans, D[ i ] - D[ i - ( N - 1 ) ] );
  }
  cout << ans << endl;
  return 0;
}
0