結果
| 問題 |
No.568 じゃんじゃん 落とす 委員会
|
| コンテスト | |
| ユーザー |
Hyado
|
| 提出日時 | 2019-06-17 14:29:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,557 bytes |
| コンパイル時間 | 1,597 ms |
| コンパイル使用メモリ | 173,392 KB |
| 実行使用メモリ | 7,168 KB |
| 最終ジャッジ日時 | 2024-11-27 11:44:18 |
| 合計ジャッジ時間 | 4,714 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 1 RE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);
signed main(){
ll n,m,nk=0,sk=0,ans=INF;
cin>>n>>m;
ll cnt[n];//index i番目の完答数
vector<pair<ll,ll>> f(n),s(n);
for(int i=0;i < n;i++)
{
cin>>cnt[i];
cnt[i]++;
cin>>f.at(i).fi>>s.at(i).fi;
f.at(i).se=i;
s.at(i).se=i;
if(cnt[i]>=3){
sk++;
nk++;
}else if(cnt[i]>=2){
nk++;
}
}
sort(f.begin(),f.end());
sort(s.begin(),s.end());
ll l=0,r=n;
if(nk>=m)ans=min(ans,sk);
for(int l=0;l <= n;l++)
{
if(l>0){
cnt[f.at(l-1).se]--;
if(cnt[f.at(l-1).se]==2){
sk--;
}else if(cnt[f.at(l-1).se]==1){
nk--;
}
if(l<n && f.at(l-1).fi==f.at(l).fi){
continue;
}
}
while(m>nk || (r<n-1 &&s.at(r).fi==s.at(r+1).fi)){
if(r>-1) r--;
else break;
if(r<n-1){
cnt[s.at(r+1).se]++;
if(cnt[s.at(r+1).se]==3){
sk++;
}else if(cnt[s.at(r+1).se]==2){
nk++;
}
}
}
//if(ans>sk)cout << l<<" "<<r << endl;
ans=min(ans,sk);
}
cout << ans << endl;
}
Hyado