結果

問題 No.230 Splarraay スプラレェーイ
ユーザー koyumeishikoyumeishi
提出日時 2015-06-11 05:00:03
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 867 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 74,588 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 20:44:25
合計ジャッジ時間 8,527 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include "assert.h"
using namespace std;

int main(){
	int n,q;
	cin >> n >> q;
	vector<int> a(n);
	long long ans_a = 0;
	long long ans_b = 0;

	for(int i=0; i<q; i++){
		int x,l,r;
		cin >> x >> l >> r;

		if(x==0){
			int cnt_a = 0;
			int cnt_b = 0;
			for(int k=l; k<=r; k++){
				if(a[k]==0) continue;
				(a[k]==1?cnt_a:cnt_b)++;
			}

			if(cnt_a == cnt_b) continue;
			(cnt_a>cnt_b?ans_a:ans_b) += max(cnt_a, cnt_b);

		}else{
			for(int k=l; k<=r; k++){
				a[k] = x;
			}
		}
	}

	int cnt_a = 0;
	int cnt_b = 0;
	for(int k=0; k<n; k++){
		if(a[k]==0) continue;
		(a[k]==1?cnt_a:cnt_b)++;
	}

	ans_a += cnt_a;
	ans_b += cnt_b;

	cout << ans_a << " " << ans_b << endl;
	return 0;
}
0