結果

問題 No.1623 三角形の制作
ユーザー CleyLCleyL
提出日時 2023-06-19 16:27:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 515 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 76,776 KB
実行使用メモリ 285,460 KB
最終ジャッジ日時 2023-09-09 11:49:02
合計ジャッジ時間 12,977 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 388 ms
284,968 KB
testcase_01 AC 379 ms
284,944 KB
testcase_02 AC 458 ms
284,960 KB
testcase_03 AC 449 ms
285,460 KB
testcase_04 AC 454 ms
285,344 KB
testcase_05 AC 507 ms
285,208 KB
testcase_06 AC 402 ms
285,260 KB
testcase_07 AC 449 ms
284,908 KB
testcase_08 AC 409 ms
285,332 KB
testcase_09 AC 447 ms
284,916 KB
testcase_10 AC 486 ms
284,904 KB
testcase_11 AC 463 ms
285,280 KB
testcase_12 AC 420 ms
285,340 KB
testcase_13 AC 430 ms
284,916 KB
testcase_14 AC 422 ms
284,964 KB
testcase_15 AC 497 ms
285,284 KB
testcase_16 AC 493 ms
285,332 KB
testcase_17 AC 498 ms
284,904 KB
testcase_18 AC 515 ms
285,360 KB
testcase_19 AC 434 ms
285,264 KB
testcase_20 AC 383 ms
285,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;cin>>n;
  vector<long long> r(3001), g(3001), b(3001);
  for(int i = 0; n > i; i++){
    int x;cin>>x;r[x]++;
  }
  for(int i = 0; n > i; i++){
    int x;cin>>x;g[x]++;
  }
  for(int i = 0; n > i; i++){
    int x;cin>>x;b[x]++;
  }
  vector<vector<long long>> z(6002, vector<long long>(3002));
  vector<vector<long long>> Z(6002, vector<long long>(3002));
  for(int i = 1; 3000 >= i; i++){
    for(int j = 0; 3000 >= j; j++){
      z[i+j][max(i,j)] += g[i]*b[j];
    }
  }


  for(int i = 0; 6001 >= i; i++){
    for(int j = 1; 3001 >= j; j++){
      Z[i][j] = Z[i][j-1]+z[i][j-1];
    }
  }
  for(int i = 1; 6001 >= i; i++){
    for(int j = 0; 3001 >= j; j++){
      Z[i][j] = Z[i][j]+Z[i-1][j];
    }
  }
  long long ans = 0;
  for(int i = 1; 3000 >= i; i++){
    ans += r[i]*(Z[6001][i+1]-Z[6001][0]-Z[i][i]+Z[i][0]);
  }
  cout << ans << endl;
}
0