結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー FF256grhyFF256grhy
提出日時 2017-09-13 23:47:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 175 ms / 1,000 ms
コード長 2,580 bytes
コンパイル時間 1,857 ms
コンパイル使用メモリ 167,844 KB
実行使用メモリ 28,828 KB
最終ジャッジ日時 2023-08-20 09:48:53
合計ジャッジ時間 5,296 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
28,828 KB
testcase_01 AC 148 ms
28,744 KB
testcase_02 AC 26 ms
22,084 KB
testcase_03 AC 25 ms
22,180 KB
testcase_04 AC 25 ms
22,132 KB
testcase_05 AC 21 ms
22,168 KB
testcase_06 AC 25 ms
22,152 KB
testcase_07 AC 25 ms
22,080 KB
testcase_08 AC 19 ms
22,156 KB
testcase_09 AC 20 ms
22,260 KB
testcase_10 AC 20 ms
22,080 KB
testcase_11 AC 25 ms
22,160 KB
testcase_12 AC 144 ms
28,464 KB
testcase_13 AC 157 ms
28,536 KB
testcase_14 AC 149 ms
28,484 KB
testcase_15 AC 159 ms
28,524 KB
testcase_16 AC 155 ms
28,236 KB
testcase_17 AC 147 ms
28,260 KB
testcase_18 AC 152 ms
28,292 KB
testcase_19 AC 175 ms
28,420 KB
testcase_20 AC 141 ms
28,648 KB
testcase_21 AC 161 ms
28,212 KB
testcase_22 AC 147 ms
28,748 KB
testcase_23 AC 26 ms
22,072 KB
testcase_24 AC 21 ms
22,156 KB
testcase_25 AC 21 ms
22,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, x[100000], a[100000], b[100000];
vector<int> va[4][100001];
vector<int> vb[4][100001];
int sa, sb, c[4][2][2];
const int LIM = 100001;

int f(int x) {
	int v = 0;
	inc(i, 4) {
	inc(j, 2) {
	inc(k, 2) {
		if(x == 2 && i + j + k >= 2) { v += c[i][j][k]; }
		if(x == 3 && i + j + k >= 3) { v += c[i][j][k]; }
	}
	}
	}
	return v;
}

bool ai() {
	if(sa == LIM) { return false; }
	inc(i, 4) {
	inc(j, va[i][sa].size()) {
		c[i][0][sb <= va[i][sa][j]]++;
		c[i][1][sb <= va[i][sa][j]]--;
	}
	}
	sa++;
	return true;
}

bool bd() {
	if(sb == 0) { return false; }
	sb--;
	inc(i, 4) {
	inc(j, vb[i][sb].size()) {
		c[i][sa <= vb[i][sb][j]][1]++;
		c[i][sa <= vb[i][sb][j]][0]--;
	}
	}
	return true;
}

int main() {
	cin >> n >> m;
	inc(i, n) { cin >> x[i] >> a[i] >> b[i]; }
	
	inc(i, n) {
		va[x[i]][a[i]].PB(b[i]);
		vb[x[i]][b[i]].PB(a[i]);
	}
	
	sa = 0;
	sb = LIM;
	inc(i, n) { c[x[i]][sa <= a[i]][sb <= b[i]]++; }
	
	int ans = n;
	do {
		if(f(2) >= m) { setmin(ans, f(3)); }
	} while((f(2) >= m ? ai() : bd()));
	
	cout << ans << endl;
	
	return 0;
}
0