結果

問題 No.3116 More and more teleporter
コンテスト
ユーザー ACF37
提出日時 2025-04-19 21:29:29
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,415 ms
コンパイル使用メモリ 185,232 KB
実行使用メモリ 9,908 KB
最終ジャッジ日時 2026-10-28 21:40:47
合計ジャッジ時間 10,640 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0