結果

問題 No.789 範囲の合計
ユーザー ohreitetsuohreitetsu
提出日時 2019-03-12 22:28:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 590 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 76,412 KB
実行使用メモリ 8,776 KB
最終ジャッジ日時 2023-09-05 20:28:53
合計ジャッジ時間 3,355 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,720 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
map<LL,LL> myMap;
map<LL,LL>::iterator mit;
LL Sumary(LL l,LL r)
{
	LL Sum=0;
	for (mit=myMap.begin();mit!=myMap.end();mit++){
		if ((*mit).first>=l && (*mit).first<=r){
			Sum+=(*mit).second;
		}
	}
	return Sum;
}
int main(int argc, char* argv[])
{
	int N;
	cin>>N;


	LL q,x,y;
	LL Sum=0;
	for (int i=0;i<N;i++){
		cin>>q>>x>>y;
		if (q==0){
			mit=myMap.find(x);
			if (mit!=myMap.end()){
				(*mit).second+=y;
			}else{
				myMap[x]=y;
			}
		}else{
			Sum+=Sumary(x,y);
		}
	}
	cout<<Sum<<endl;
	return 0;
}
0