結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー FF256grhyFF256grhy
提出日時 2017-09-13 23:50:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 1,000 ms
コード長 2,518 bytes
コンパイル時間 1,741 ms
コンパイル使用メモリ 170,412 KB
実行使用メモリ 28,932 KB
最終ジャッジ日時 2024-05-07 16:51:33
合計ジャッジ時間 4,289 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
28,932 KB
testcase_01 AC 113 ms
28,928 KB
testcase_02 AC 12 ms
22,272 KB
testcase_03 AC 12 ms
22,272 KB
testcase_04 AC 12 ms
22,400 KB
testcase_05 AC 11 ms
22,144 KB
testcase_06 AC 12 ms
22,272 KB
testcase_07 AC 12 ms
22,272 KB
testcase_08 AC 10 ms
22,144 KB
testcase_09 AC 11 ms
22,272 KB
testcase_10 AC 10 ms
22,272 KB
testcase_11 AC 11 ms
22,272 KB
testcase_12 AC 114 ms
28,672 KB
testcase_13 AC 113 ms
28,800 KB
testcase_14 AC 106 ms
28,544 KB
testcase_15 AC 111 ms
28,800 KB
testcase_16 AC 108 ms
28,288 KB
testcase_17 AC 100 ms
28,416 KB
testcase_18 AC 107 ms
28,416 KB
testcase_19 AC 114 ms
28,416 KB
testcase_20 AC 103 ms
28,496 KB
testcase_21 AC 104 ms
28,352 KB
testcase_22 AC 109 ms
28,928 KB
testcase_23 AC 12 ms
22,272 KB
testcase_24 AC 9 ms
22,272 KB
testcase_25 AC 10 ms
22,272 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 <= i + j + k) { 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