結果

問題 No.2662 Installing Cell Towers
ユーザー 👑 NachiaNachia
提出日時 2024-03-06 15:41:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 989 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 95,328 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-06 15:41:39
合計ジャッジ時間 3,119 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 4 ms
6,548 KB
testcase_05 AC 27 ms
6,548 KB
testcase_06 AC 17 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 14 ms
6,548 KB
testcase_09 AC 4 ms
6,548 KB
testcase_10 AC 28 ms
6,548 KB
testcase_11 AC 24 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 20 ms
6,548 KB
testcase_14 AC 31 ms
6,548 KB
testcase_15 AC 26 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 31 ms
6,548 KB
testcase_18 AC 30 ms
6,548 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <array>
#include <cmath>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(auto i=0LL; i<(long long)(n); i++)
#define repr(i,n) for(auto i=(long long)(n)-1LL; i>=0LL; i--)
using namespace std;

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    i64 N, M; cin >> N >> M;
    vector<i64> X(N+3);
    vector<i64> C(N+3);
    rep(i,M){
        i64 p,q; cin >> p >> q; p--;
        i64 l = max<i64>(0, p-q+1);
        i64 r = min<i64>(N, p+q);

        i64 h1 = q - p;
        X[l] += 1;
        C[l] += h1;
        X[p] -= 1;
        C[p] -= h1;

        i64 h2 = q + p;
        X[p] -= 1;
        C[p] += h2;
        X[r] += 1;
        C[r] -= h2;
    }
    rep(i,N+2) X[i+1] += X[i];
    rep(i,N+2) C[i+1] += C[i];
    rep(i,N){
        if(i) cout << ' ';
        cout << (X[i] * i + C[i]);
    } cout << '\n';
    return 0;
}
0