結果

問題 No.1623 三角形の制作
ユーザー SSRSSSRS
提出日時 2021-07-23 21:25:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 614 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 3,126 ms
コンパイル使用メモリ 170,448 KB
実行使用メモリ 5,568 KB
最終ジャッジ日時 2023-09-25 21:10:16
合計ジャッジ時間 10,406 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
4,376 KB
testcase_01 AC 45 ms
4,380 KB
testcase_02 AC 521 ms
4,380 KB
testcase_03 AC 515 ms
4,380 KB
testcase_04 AC 516 ms
4,392 KB
testcase_05 AC 614 ms
5,568 KB
testcase_06 AC 394 ms
4,380 KB
testcase_07 AC 518 ms
4,388 KB
testcase_08 AC 396 ms
4,376 KB
testcase_09 AC 512 ms
4,380 KB
testcase_10 AC 576 ms
4,800 KB
testcase_11 AC 528 ms
4,580 KB
testcase_12 AC 229 ms
4,376 KB
testcase_13 AC 230 ms
4,380 KB
testcase_14 AC 227 ms
4,380 KB
testcase_15 AC 315 ms
5,352 KB
testcase_16 AC 316 ms
5,448 KB
testcase_17 AC 332 ms
5,372 KB
testcase_18 AC 331 ms
5,408 KB
testcase_19 AC 253 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