結果

問題 No.789 範囲の合計
ユーザー ohreitetsuohreitetsu
提出日時 2019-03-13 21:37:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 75,536 KB
実行使用メモリ 10,012 KB
最終ジャッジ日時 2023-09-06 05:42:22
合計ジャッジ時間 3,603 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,772 KB
testcase_01 WA -
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;
	map<LL,LL>::iterator mitL,mitR;
	mitL=myMap.find(l);
	mitR=myMap.find(r);
	mit=mitL;
	while (mit!=mitR){
		Sum+=(*mit).second;
		//cout<<Sum<<endl;
		mit++;
	}
	return Sum;
}
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	int q;
	LL 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{
			mit=myMap.find(x);
			if (mit==myMap.end()){
				myMap[x]=0;
			}
			mit=myMap.find(y);
			if (mit==myMap.end()){
				myMap[y]=0;
			}
			Sum+=Sumary(x,y);
		}
	}
	cout<<Sum<<endl;
	return 0;
}
0