結果
| 問題 |
No.370 道路の掃除
|
| コンテスト | |
| ユーザー |
rickytheta
|
| 提出日時 | 2016-05-13 22:26:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 948 bytes |
| コンパイル時間 | 1,355 ms |
| コンパイル使用メモリ | 160,548 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 16:41:14 |
| 合計ジャッジ時間 | 2,215 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:27:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | REP(i,m)scanf("%d",d+i);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
int n,m;
int d[1001];
int main(){
scanf("%d%d",&n,&m);
REP(i,m)scanf("%d",d+i);
sort(d,d+m);
int mn = 830252521;
REP(i,m-n+1){
int lmost = d[i];
int rmost = d[i+n-1];
if(rmost<=0||0<=lmost){
mn=min(mn,max(abs(rmost),abs(lmost)));
}else{
int x = abs(lmost);
int y = abs(rmost);
if(x>y)swap(x,y);
mn=min(mn,2*x+y);
}
}
printf("%d\n",mn);
return 0;
}
rickytheta