結果

問題 No.1623 三角形の制作
ユーザー msm1993msm1993
提出日時 2021-07-28 10:59:39
言語 C++14
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 601 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 169,804 KB
実行使用メモリ 5,540 KB
最終ジャッジ日時 2023-07-11 14:28:20
合計ジャッジ時間 12,358 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
4,380 KB
testcase_01 AC 45 ms
4,376 KB
testcase_02 AC 517 ms
4,416 KB
testcase_03 AC 511 ms
4,420 KB
testcase_04 AC 501 ms
4,376 KB
testcase_05 AC 601 ms
5,540 KB
testcase_06 AC 391 ms
4,380 KB
testcase_07 AC 517 ms
4,484 KB
testcase_08 AC 395 ms
4,376 KB
testcase_09 AC 507 ms
4,384 KB
testcase_10 AC 568 ms
4,740 KB
testcase_11 AC 524 ms
4,680 KB
testcase_12 AC 227 ms
4,384 KB
testcase_13 AC 229 ms
4,380 KB
testcase_14 AC 227 ms
4,376 KB
testcase_15 AC 314 ms
5,316 KB
testcase_16 AC 313 ms
5,264 KB
testcase_17 AC 330 ms
5,272 KB
testcase_18 AC 333 ms
5,408 KB
testcase_19 AC 249 ms
4,376 KB
testcase_20 AC 44 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int MAX = 3001;
int main(){
  int n;
  cin >> n;
  vector<int> r(n);
  for (int i = 0; i < n; i++){
    cin >> r[i];
  }
  vector<int> g(n);
  for (int i = 0; i < n; i++){
    cin >> g[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }
  vector<int> rc(MAX, 0);
  for (int i = 0; i < n; i++){
    rc[r[i]]++;
  }
  vector<int> gc(MAX, 0);
  for (int i = 0; i < n; i++){
    gc[g[i]]++;
  }
  sort(b.begin(), b.end());
  long long ans = 0;
  for (int i = 0; i < MAX; i++){
    for (int j = 0; j <= i; j++){
      int l = upper_bound(b.begin(), b.end(), i - j) - b.begin();;
      int r = upper_bound(b.begin(), b.end(), i) - b.begin();
      ans += (long long) rc[i] * gc[j] * (r - l);
    }
  }
  cout << ans << endl;
}
0