結果
| 問題 |
No.568 じゃんじゃん 落とす 委員会
|
| コンテスト | |
| ユーザー |
ojisan_IT
|
| 提出日時 | 2017-09-24 15:21:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,865 bytes |
| コンパイル時間 | 1,088 ms |
| コンパイル使用メモリ | 91,052 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-14 07:09:14 |
| 合計ジャッジ時間 | 4,236 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 WA * 1 |
ソースコード
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
#include<algorithm>
#include<tuple>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define mt make_tuple
typedef tuple<int,int> tii;
vector<int> x(100001);
int main(){
int n,m; cin >> n >> m;
vector<tii> a;
vector<tii> b;
rep(i,n){
int xx,aa,bb; cin >> xx >> aa >> bb;
a.pb(tii{i,aa});
b.pb(tii{i,bb});
x[i] = xx+1;
}
sort(ALL(a),[](tii a,tii b){return get<1>(a) < get<1>(b);});
sort(ALL(b),[](tii a,tii b){return get<1>(a) < get<1>(b);});
int ans = INF;
int now_a = -1, now_b = 100001;
int a_index = 0, b_index = n-1;
int cnt[6] = {};
rep(i,n){cnt[x[i]]++;}
while(now_a < 100001 && now_b >= -1){
// SHOW(now_a,now_b);
// rep(i,6)cerr <<" "<<cnt[i]; cerr<<endl;
if(cnt[2]+cnt[3]+cnt[4]+cnt[5] >= m){
ans = min(ans,cnt[3]+cnt[4]+cnt[5]);
now_a++;
for(;a_index < n && get<1>(a[a_index]) < now_a; a_index++){
cnt[x[get<0>(a[a_index])]]--;
x[get<0>(a[a_index])]--;
cnt[x[get<0>(a[a_index])]]++;
}
}else{
now_b--;
for(;b_index >= 0 && get<1>(b[b_index]) > now_b; b_index--){
cnt[x[get<0>(b[b_index])]]--;
x[get<0>(b[b_index])]++;
cnt[x[get<0>(b[b_index])]]++;
}
}
}
cout << ans << endl;
}
ojisan_IT