結果

問題 No.2662 Installing Cell Towers
ユーザー aplysiaistpaplysiaistp
提出日時 2023-03-08 01:42:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 205,372 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-16 02:04:47
合計ジャッジ時間 4,061 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 6 ms
6,676 KB
testcase_05 AC 68 ms
6,676 KB
testcase_06 AC 52 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 35 ms
6,676 KB
testcase_09 AC 7 ms
6,676 KB
testcase_10 AC 75 ms
6,676 KB
testcase_11 AC 70 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 62 ms
6,676 KB
testcase_14 AC 79 ms
6,676 KB
testcase_15 AC 59 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 86 ms
6,676 KB
testcase_18 AC 85 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(m), q(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> q[i];
    }

    vector<long long> imos(n + 1);
    for (int i = 0; i < m; i++) {
        if (q[i] - p[i] + 1 > 0) {
            imos[0] += q[i] - p[i] + 1;
            imos[1] -= q[i] - p[i];
        } else {
            imos[p[i] - q[i]]++;
        }
        imos[p[i]]--;
        imos[p[i]]--;
        if (q[i] + p[i] <= n) {
            imos[p[i] + q[i]]++;
        }
    }

    for (int i = 1; i <= n; i++) {
        imos[i] += imos[i - 1];
    }
    for (int i = 1; i <= n; i++) {
        imos[i] += imos[i - 1];
    }

    for (int i = 0; i < n; i++) {
        cout << imos[i] << ' ';
    }
    cout << endl;
}
0