結果

問題 No.1679 マスゲーム
ユーザー keijakkeijak
提出日時 2021-09-13 02:15:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,173 bytes
コンパイル時間 3,416 ms
コンパイル使用メモリ 197,608 KB
実行使用メモリ 6,732 KB
最終ジャッジ日時 2023-09-07 05:20:46
合計ジャッジ時間 6,272 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 61 ms
6,516 KB
testcase_04 AC 61 ms
6,548 KB
testcase_05 AC 62 ms
6,456 KB
testcase_06 AC 62 ms
6,496 KB
testcase_07 AC 61 ms
6,460 KB
testcase_08 AC 63 ms
6,628 KB
testcase_09 AC 61 ms
6,688 KB
testcase_10 AC 60 ms
6,464 KB
testcase_11 AC 59 ms
6,552 KB
testcase_12 AC 9 ms
6,568 KB
testcase_13 AC 27 ms
6,516 KB
testcase_14 AC 60 ms
6,556 KB
testcase_15 AC 52 ms
6,692 KB
testcase_16 AC 46 ms
6,732 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 47 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP_(i, a_, b_, a, b, ...) \
  for (int i = (a), END_##i = (b); i < END_##i; ++i)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
using i64 = long long;

void print() { std::cout << "\n"; }
template<class T>
void print(const T &x) {
  std::cout << x << "\n";
}
template<typename Head, typename... Tail>
void print(const Head &head, Tail... tail) {
  std::cout << head << " ";
  print(tail...);
}

struct Input {
  template<typename T>
  operator T() const {
    T x;
    std::cin >> x;
    return x;
  }
} in;

#ifdef MY_DEBUG
#include "debug_dump.hpp"
#else
#define DUMP(...)
#endif

using namespace std;

int m0[400020];
int m1[400020];
const int kOffset = 200010;

auto solve() {
  const int n = in;
  int mx = 0, mn = 2 * kOffset;
  REP(i, n) {
    const int a = in, b = in, t = in;
    int x = b - t + kOffset;
    if (a == 0) {
      ++m0[x];
    } else {
      ++m1[x];
    }
    mx = max(mx, x);
    mn = min(mn, x);
  }
  i64 ans = 0;
  for (int i = mn; i <= mx; ++i) {
    ans += i64(m0[i]) * m1[i];
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  print(solve());
}
0