結果

問題 No.2662 Installing Cell Towers
ユーザー aplysiaistpaplysiaistp
提出日時 2023-03-08 01:35:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 790 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 203,440 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-16 02:04:41
合計ジャッジ時間 3,783 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 7 ms
6,676 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 34 ms
6,676 KB
testcase_09 AC 7 ms
6,676 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,676 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 59 ms
6,676 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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<int> 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