結果

問題 No.1679 マスゲーム
ユーザー atjh16
提出日時 2021-09-11 19:03:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 173,320 KB
実行使用メモリ 5,584 KB
最終ジャッジ日時 2024-06-23 03:26:59
合計ジャッジ時間 4,880 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n, a, b, t, w = -200000;
long long c = 0, d = 0, m = 0;
vector<pair<int, int>> v;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a >> b >> t;

		v.push_back({ b - t, a });
	}

	sort(v.begin(), v.end());

	for (auto u : v) {
		if (w != u.first){
			m += c * d;
			w = u.first;
			c = 0;
			d = 0;
		}

		if (u.second)
			c++;
		else
			d++;
	}

	m += c * d;

	cout << m << endl;
}
0