結果
| 問題 |
No.2673 A present from B
|
| コンテスト | |
| ユーザー |
てんぷら
|
| 提出日時 | 2024-03-15 21:38:01 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 208 ms / 2,000 ms |
| コード長 | 895 bytes |
| コンパイル時間 | 4,792 ms |
| コンパイル使用メモリ | 307,364 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-30 00:32:22 |
| 合計ジャッジ時間 | 6,352 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
using namespace std;
using namespace atcoder;
using mint = modint998244353;
const int inf = 1000000007;
const ll longinf = 1ll << 60;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) cin >> a[i];
reverse(a.begin(), a.end());
vector<int> dp(n);
rep(i, n) {
dp[i] = i;
}
rep(t, m) {
vector<int> ndp(n, inf);
swap(dp[a[t] - 1], dp[a[t]]);
rep(i, n) rep(ni, n) {
ndp[ni] = min(ndp[ni], dp[i] + abs(i - ni));
}
dp.swap(ndp);
}
rep(i, n - 1) cout << dp[i + 1] << " \n"[i + 2 == n];
return 0;
}
てんぷら