結果
| 問題 |
No.370 道路の掃除
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-03-14 15:52:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,204 bytes |
| コンパイル時間 | 2,341 ms |
| コンパイル使用メモリ | 196,456 KB |
| 実行使用メモリ | 17,848 KB |
| 最終ジャッジ日時 | 2025-03-14 15:52:09 |
| 合計ジャッジ時間 | 8,886 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | freopen("clean.in","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:22:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | freopen("clean.out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define MAXN 1005
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
inline void print(int x){
static int s[20],t=0;
do s[++t]=x%10,x/=10;while(x);
while(t) putchar(s[t--] + '0');
}
int n;int m,cnt=0;
int a[MAXN];
int dis[MAXN];
signed main(){
freopen("clean.in","r",stdin);
freopen("clean.out","w",stdout);
n=read();m=read();
vector<int> d(m);
for(int i=0;i<m;i++){
d[i]=read();
}
sort(d.begin(), d.end());
int minn=1e9;
for(int i=0;i<m;i++){
int st=i+n-1;
if(st>=m) break;
for(int j=st;j<m;j++){
int L=d[i];
int R=d[j];
int cur=(R-L)+min(abs(L),abs(R));
minn=min(minn,cur);
}
}
cout<<minn;
return 0;
}
// ?????????????????????????
// ??????????????????
// ????????????????????????????????????
// ???????????????????????????????
// ????????????
// ????????????
// ????????????
// ????????????????????
// ????????????????????
// ????????????????????????????????
// ???????????????????????
// ???????????
// ?????????????
vjudge1