結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー kotamanegikotamanegi
提出日時 2017-09-23 23:52:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 50 ms / 1,000 ms
コード長 1,931 bytes
コンパイル時間 1,054 ms
コンパイル使用メモリ 114,884 KB
実行使用メモリ 6,024 KB
最終ジャッジ日時 2023-08-20 09:49:18
合計ジャッジ時間 3,063 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
5,904 KB
testcase_01 AC 49 ms
5,912 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 49 ms
5,944 KB
testcase_13 AC 50 ms
5,892 KB
testcase_14 AC 49 ms
5,932 KB
testcase_15 AC 49 ms
5,948 KB
testcase_16 AC 47 ms
5,744 KB
testcase_17 AC 46 ms
5,840 KB
testcase_18 AC 47 ms
6,024 KB
testcase_19 AC 49 ms
5,984 KB
testcase_20 AC 47 ms
5,800 KB
testcase_21 AC 47 ms
5,892 KB
testcase_22 AC 49 ms
5,924 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 262144
int aced[200000] = {};
int itr[2] = {};
int getting[10] = {};
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int,int>> wow;
	vector<tuple<int, int, int>> upper;
	REP(i, n) {
		int a, b, c;
		cin >> a >> b >> c;
		aced[i] = a+1;
		getting[a+1]++;
		upper.push_back(make_tuple(c, b, i));
		wow.push_back(make_tuple(b, c,i));
	}
	sort(wow.begin(), wow.end());
	sort(upper.begin(), upper.end(), greater<tuple<int, int, int>>());
	int ans = 1000000;
	for (int i = -1;i <= 100000;++i) {
		while(itr[0] != n&&i == get<0>(wow[itr[0]])) {
			getting[aced[get<2>(wow[itr[0]])]]--;
			aced[get<2>(wow[itr[0]])]--;
			getting[aced[get<2>(wow[itr[0]])]]++;
			itr[0]++;
		}
		while (getting[2]+getting[3]+getting[4]+getting[5] < m) {
		gogo:;
			if (itr[1] == n) goto ok;
			getting[aced[get<2>(upper[itr[1]])]]--;
			aced[get<2>(upper[itr[1]])]++;
			getting[aced[get<2>(upper[itr[1]])]]++;
			itr[1]++;
			if (itr[1] != n&&get<0>(upper[itr[1]]) == get<0>(upper[itr[1] - 1])) goto gogo;
		}
		ans = min(ans, getting[3]+getting[4]+getting[5]);
	}
ok:;
	cout << ans << endl;
	return 0;
}
0