結果

問題 No.1705 Mode of long array
ユーザー harurunharurun
提出日時 2021-09-19 17:13:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,510 bytes
コンパイル時間 8,414 ms
コンパイル使用メモリ 304,480 KB
実行使用メモリ 4,484 KB
最終ジャッジ日時 2023-09-30 09:36:58
合計ジャッジ時間 12,710 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using ll=long long;

const ll MIN_N=1;
const ll MAX_N=500000000000000000LL;
const ll MIN_M=1;
const ll MAX_M=100000;
const ll MIN_A=0;
const ll MIN_Q=1;
const ll MAX_Q=100000;
const ll MIN_T=1;
const ll MAX_T=3;
const ll MIN_X=1;
const ll MIN_Y=1;
const ll MAX_Y=1000000000000LL;


int main(){
  registerValidation();
  ll N,M;
  N=inf.readLong(MIN_N,MAX_N);
  inf.readSpace();
  M=inf.readLong(MIN_M,MAX_M);
  inf.readEoln();
  
  vector<ll>a(M);
  ll sum=0;
  for(ll i=0;i<M;i++){
    a.at(i)=inf.readLong(MIN_A,N);
    sum+=a.at(i);
    if(i!=M-1){
      inf.readSpace();
    }
  }
  inf.readEoln();
  
  assert(sum==N);

  ll cnt=0;
  for(ll i=0;i<M;i++){
    if(a.at(i)>0){
      cnt++;
    }
  }
  bool flag=false;
  ll Q;
  Q=inf.readLong(MIN_Q,MAX_Q);
  inf.readEoln();
  for(ll i=0;i<Q;i++){
    ll T,X,Y;
    T=inf.readLong(MIN_T,MAX_T);
    inf.readSpace();
    if(T==1){
      X=inf.readLong(MIN_X,M);
      inf.readSpace();
      Y=inf.readLong(MIN_Y,MAX_Y);
      if(a.at(X-1)==0){
        cnt++;
      }
      a.at(X-1)+=Y;
    }else if(T==2){
      X=inf.readLong(MIN_X,M);
      inf.readSpace();
      Y=inf.readLong(MIN_Y,MAX_Y);
      a.at(X-1)-=Y;
      if(a.at(X-1)==0){
        cnt--;
      }
    }else{
      X=inf.readLong(0LL,0LL);
      inf.readSpace();
      Y=inf.readLong(0LL,0LL);
      flag=true;
    }
    inf.readEoln();
    assert(cnt>0);
  }
  assert(flag);
  inf.readEof();
  return 0;
}
0