結果
問題 | No.370 道路の掃除 |
ユーザー |
|
提出日時 | 2017-12-03 02:50:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 344 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 70,512 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 08:05:12 |
合計ジャッジ時間 | 2,026 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int n,a[1<<17],m; main() { cin>>n>>m; for(int i=0;i<m;i++)cin>>a[i]; sort(a,a+m); int ans=1e9; for(int i=0;i<=m-n;i++) { int now; if(a[i+n-1]<0)now=-a[i]; else if(a[i]>0)now=a[i+n-1]; else now=a[i+n-1]-a[i]+min(a[i+n-1],-a[i]); ans=min(ans,now); } cout<<ans<<endl; }