結果

問題 No.370 道路の掃除
ユーザー かにかに
提出日時 2016-10-14 22:37:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 841 bytes
コンパイル時間 1,227 ms
コンパイル使用メモリ 161,940 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 23:30:24
合計ジャッジ時間 2,257 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:38:26: warning: ‘t’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |                 p = pos[t];
      |                          ^

ソースコード

diff #

#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, 0,-1,0 };
int dy[] = { 0, 1,0,-1 };

void solve() {
	int n, m;
	cin >> n >> m;
	vi pos;
	rep(i, m) {
		int a;
		cin >> a;
		pos.push_back(a);
	}
	int p = 0;
	int cost = 0;
	rep(i, n){
		int mini = 25252;
		int t;
		rep(j, pos.size()) {
			if (abs(p - pos[j]) < mini) {
				mini = abs(p - pos[j]);
				t = j;
			}
		}
		cost += mini;
		p = pos[t];
		pos.erase(pos.begin() + t);
	}
	P(cost);
}

int main() {
	solve();
	return 0;
}
0