結果

問題 No.2662 Installing Cell Towers
ユーザー 2bit2bit
提出日時 2023-03-05 00:25:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 203,688 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-16 02:03:45
合計ジャッジ時間 4,059 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 7 ms
6,548 KB
testcase_05 AC 72 ms
6,548 KB
testcase_06 AC 52 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 33 ms
6,676 KB
testcase_09 AC 7 ms
6,676 KB
testcase_10 AC 78 ms
6,676 KB
testcase_11 AC 67 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 61 ms
6,676 KB
testcase_14 AC 83 ms
6,676 KB
testcase_15 AC 63 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 88 ms
6,676 KB
testcase_18 AC 88 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;cin >> N >> M;
  vector<long long> ans(N+2),S(N+2);
  auto add = [](vector<long long> &A,int l,int r,int C)->void{
    A[l] += C;
    A[r] -= C;
  };
  while(M--){
    int p,q;cin >> p >> q;
    int a = q - p;
    add(ans,min(max(p-q+1,1),p),p,a);
    add(S,min(max(p-q+1,1),p),p,1);
    int b = p + q;
    add(ans,p,min(b+1,N+1),b);
    add(S,p,min(b+1,N+1),-1);
  }
  for(int i=1;i<=N;i++){
    S[i+1] += S[i];
    ans[i+1] += ans[i];
    cout << ans[i] + S[i] * i << " ";
  }
  cout<<endl;
}
0