結果
| 問題 |
No.3116 More and more teleporter
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 21:29:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 524 ms / 2,000 ms |
| コード長 | 842 bytes |
| コンパイル時間 | 1,320 ms |
| コンパイル使用メモリ | 113,912 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-19 21:29:47 |
| 合計ジャッジ時間 | 7,086 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
int main() {
int N, Q;
std::cin >> N >> Q;
// 0からN-1までの数値で配列Cを初期化
std::vector<int> C(N);
for (int i = 0; i < N; i++) {
C[i] = i;
}
for (int i = 0; i < Q; i++) {
int query_type;
std::cin >> query_type;
if (query_type == 1) {
int index;
std::cin >> index;
std::cout << C[index - 1] << std::endl;
}
else if (query_type == 2) {
int x, c;
std::cin >> x >> c;
if (C[x - 1] > c) {
for (int j = 0; j < N; j++) {
C[j] = std::min(c + std::abs(x - 1 - j), C[j]);
}
}
}
}
return 0;
}