結果
| 問題 | No.789 範囲の合計 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-07-24 22:12:43 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 758 bytes |
| 記録 | |
| コンパイル時間 | 971 ms |
| コンパイル使用メモリ | 179,596 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2026-07-24 22:15:46 |
| 合計ジャッジ時間 | 2,839 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int M=200010;
int q,m,c[M],o[M][3],a[M],s;
void u(int i,int x){for(;i<=m;i+=i&-i)a[i]+=x;}
int qy(int i){int t=0;for(;i;i-=i&-i)t+=a[i];return t;}
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin>>q;
for(int i=0;i<q;++i){
cin>>o[i][0]>>o[i][1]>>o[i][2];
if(o[i][0])c[m++]=o[i][1],c[m++]=o[i][2];
else c[m++]=o[i][1];
}
sort(c,c+m);
m=unique(c,c+m)-c;
for(int i=0;i<q;++i){
if(o[i][0]){
int l=lower_bound(c,c+m,o[i][1])-c;
int r=upper_bound(c,c+m,o[i][2])-c-1;
if(l<=r)s+=qy(r+1)-qy(l);
}else{
int p=lower_bound(c,c+m,o[i][1])-c;
u(p+1,o[i][2]);
}
}
cout<<s;
}
vjudge1