結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー koprickykopricky
提出日時 2017-09-10 06:21:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 54 ms / 1,000 ms
コード長 2,001 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 161,760 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2024-05-07 16:50:54
合計ジャッジ時間 3,559 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
13,000 KB
testcase_01 AC 51 ms
13,184 KB
testcase_02 AC 6 ms
8,320 KB
testcase_03 AC 4 ms
8,192 KB
testcase_04 AC 5 ms
8,136 KB
testcase_05 AC 5 ms
8,260 KB
testcase_06 AC 5 ms
8,192 KB
testcase_07 AC 5 ms
8,132 KB
testcase_08 AC 4 ms
8,192 KB
testcase_09 AC 5 ms
8,320 KB
testcase_10 AC 4 ms
8,136 KB
testcase_11 AC 5 ms
8,192 KB
testcase_12 AC 49 ms
12,948 KB
testcase_13 AC 50 ms
12,800 KB
testcase_14 AC 50 ms
12,864 KB
testcase_15 AC 51 ms
12,928 KB
testcase_16 AC 48 ms
12,612 KB
testcase_17 AC 48 ms
12,800 KB
testcase_18 AC 53 ms
12,800 KB
testcase_19 AC 52 ms
12,740 KB
testcase_20 AC 54 ms
12,800 KB
testcase_21 AC 49 ms
12,672 KB
testcase_22 AC 49 ms
13,128 KB
testcase_23 AC 5 ms
8,132 KB
testcase_24 AC 5 ms
8,192 KB
testcase_25 AC 5 ms
8,004 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0