結果
| 問題 |
No.568 じゃんじゃん 落とす 委員会
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-10 06:21:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 1,000 ms |
| コード長 | 2,001 bytes |
| コンパイル時間 | 1,373 ms |
| コンパイル使用メモリ | 161,980 KB |
| 実行使用メモリ | 13,124 KB |
| 最終ジャッジ日時 | 2024-11-30 11:13:15 |
| 合計ジャッジ時間 | 3,074 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%d%d%d",&x[i],&a[i],&b[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
using namespace std;
typedef pair<int,int>P;
const int MAX_N = 100005;
vector<int> sa[MAX_N],sb[MAX_N];
int main()
{
int n,m;
scanf("%d%d",&n,&m);
vector<int> x(n),a(n),b(n);
rep(i,n){
scanf("%d%d%d",&x[i],&a[i],&b[i]);
x[i]++;
sa[a[i]].pb(i),sb[b[i]].pb(i);
}
int na = 0,nb = 100001;
int two=0,three=0;
rep(i,n){
if(x[i] >= 2){
two++;
if(x[i] >= 3){
three++;
}
}
}
int ans = INF;
while(1){
if(two >= m){
ans = min(ans,three);
na++;
if(na > 100001){
break;
}
rep(i,sa[na-1].size()){
x[sa[na-1][i]]--;
if(x[sa[na-1][i]] == 1){
two--;
}else if(x[sa[na-1][i]] == 2){
three--;
}
}
}else{
nb--;
if(nb < 0){
break;
}
rep(i,sb[nb].size()){
x[sb[nb][i]]++;
if(x[sb[nb][i]] == 2){
two++;
}else if(x[sb[nb][i]] == 3){
three++;
}
}
}
}
cout << ans << endl;
return 0;
}