結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー nanophoto12nanophoto12
提出日時 2017-09-10 00:17:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 162 ms / 1,000 ms
コード長 1,495 bytes
コンパイル時間 1,033 ms
コンパイル使用メモリ 93,836 KB
実行使用メモリ 55,424 KB
最終ジャッジ日時 2024-05-07 16:51:07
合計ジャッジ時間 4,894 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
55,424 KB
testcase_01 AC 156 ms
55,168 KB
testcase_02 AC 48 ms
50,432 KB
testcase_03 AC 47 ms
50,304 KB
testcase_04 AC 48 ms
50,304 KB
testcase_05 AC 45 ms
50,432 KB
testcase_06 AC 48 ms
50,432 KB
testcase_07 AC 49 ms
50,176 KB
testcase_08 AC 44 ms
50,432 KB
testcase_09 AC 44 ms
50,304 KB
testcase_10 AC 45 ms
50,432 KB
testcase_11 AC 48 ms
50,304 KB
testcase_12 AC 160 ms
54,912 KB
testcase_13 AC 159 ms
55,112 KB
testcase_14 AC 160 ms
55,168 KB
testcase_15 AC 156 ms
55,108 KB
testcase_16 AC 161 ms
54,912 KB
testcase_17 AC 148 ms
54,984 KB
testcase_18 AC 159 ms
54,912 KB
testcase_19 AC 155 ms
55,168 KB
testcase_20 AC 157 ms
54,912 KB
testcase_21 AC 154 ms
55,040 KB
testcase_22 AC 161 ms
55,424 KB
testcase_23 AC 45 ms
50,432 KB
testcase_24 AC 44 ms
50,432 KB
testcase_25 AC 44 ms
50,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef tuple<int,int,int> t3;

using namespace std;

int n,m;

#define MAX_N 1000010

int x[MAX_N];
int a[MAX_N];
int b[MAX_N];

vector<int> ai[MAX_N];
vector<int> bi[MAX_N];
int c[10];

int two()
{
    return c[2] + c[3] + c[4] + c[5];
}

int three()
{
    return c[3] + c[4] + c[5];
}

void solve()
{
    cin >> n >> m;
    for(int i = 0;i < n;i++)
    {
        cin >> x[i] >> a[i] >> b[i];
        ai[a[i]].push_back(i);
        bi[b[i]].push_back(i);
    }
    //b max
    for(int i = 0;i < n;i++)
    {
        x[i]++;
        c[x[i]]++;
    }
    ll ans = 1e15;
    int cb = 1000001;
    for(int ca = 0; ca < 1000001;ca++)
    {
        while(two() < m)
        {
            cb--;
            if(cb < 0) break;
            for(auto i : bi[cb])
            {
                c[x[i]]--;
                x[i]++;
                c[x[i]]++;
            }
        }
        if(two() < m) break;
        ans = min(ans, (ll)three());
        for(auto i : ai[ca])
        {
            c[x[i]]--;
            x[i]--;
            c[x[i]]++;
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}
0