結果
| 問題 | No.2662 Installing Cell Towers |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-04-25 18:52:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 2,000 ms |
| コード長 | 719 bytes |
| コンパイル時間 | 514 ms |
| コンパイル使用メモリ | 40,776 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 06:26:29 |
| 合計ジャッジ時間 | 2,760 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2662.cc: No.2662 Installing Cell Towers - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 100000;
/* typedef */
typedef long long ll;
/* global variables */
int es[MAX_N];
/* subroutines */
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
ll s = 0;
for (int i = 0; i < m; i++) {
int pi, qi;
scanf("%d%d", &pi, &qi); pi--;
int p0 = pi - qi, p1 = pi + qi;
s += max(0, -p0);
es[max(0, p0)]++;
es[pi] -= 2;
if (p1 < n) es[p1]++;
}
ll d = 0;
for (int i = 0; i < n; i++) {
s += d;
printf("%lld%c", s, (i + 1 < n) ? ' ' : '\n');
d += es[i];
}
return 0;
}
tnakao0123