結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー tnakao0123tnakao0123
提出日時 2017-09-22 11:20:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,690 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 89,744 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 22:45:55
合計ジャッジ時間 3,010 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
6,816 KB
testcase_01 AC 42 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 WA -
testcase_13 AC 43 ms
6,940 KB
testcase_14 AC 42 ms
6,940 KB
testcase_15 AC 42 ms
6,944 KB
testcase_16 AC 41 ms
6,940 KB
testcase_17 AC 42 ms
6,944 KB
testcase_18 AC 41 ms
6,940 KB
testcase_19 AC 43 ms
6,940 KB
testcase_20 AC 41 ms
6,944 KB
testcase_21 AC 42 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 2 ms
6,944 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |   scanf("%d%d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~
main.cpp:53:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   53 |     scanf("%d%d%d", &xi, &ai, &bi);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 568.cc: No.568 じゃんじゃん 落とす 委員会 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_A = 100000;
const int MAX_B = 100000;
const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int xs[MAX_N];
pii aps[MAX_N], bps[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < n; i++) {
    int xi, ai, bi;
    scanf("%d%d%d", &xi, &ai, &bi);
    xs[i] = xi;
    aps[i] = pii(ai, i);
    bps[i] = pii(bi, i);
  }

  sort(aps, aps + n);
  sort(bps, bps + n);

  int n2 = 0, n3 = 0;
  for (int i = 0; i < n; i++) {
    xs[i]++;
    if (xs[i] >= 2) {
      n2++;
      if (xs[i] >= 3) n3++;
    }
  }
  //printf("n2=%d, n3=%d\n", n2, n3);

  int sa = 0, sb = MAX_B + 1;
  int minn3 = INF;

  for (int ai = 0, bi = n; ai < n;) {
    while (bi > 0 && n2 < m) {
      sb--;
      while (bi > 0 && bps[bi - 1].first >= sb) {
	bi--;
	int &k = bps[bi].second;
	xs[k]++;
	if (xs[k] == 3) n3++;
	else if (xs[k] == 2) n2++;
      }
    }

    if (n2 >= m && minn3 > n3) minn3 = n3;

    while (ai < n && aps[ai].first <= sa) {
      int &k = aps[ai].second;
      if (xs[k] == 3) n3--;
      else if (xs[k] == 2) n2--;
      xs[k]--;
      ai++;
    }
    sa++;
  }

  printf("%d\n", minn3);
  return 0;
}
0