結果

問題 No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
ユーザー SSRSSSRS
提出日時 2021-10-29 21:56:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 334 ms / 3,000 ms
コード長 1,215 bytes
コンパイル時間 1,847 ms
コンパイル使用メモリ 174,960 KB
実行使用メモリ 23,264 KB
最終ジャッジ日時 2024-04-16 14:46:22
合計ジャッジ時間 8,235 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 73 ms
8,016 KB
testcase_15 AC 210 ms
13,908 KB
testcase_16 AC 284 ms
15,576 KB
testcase_17 AC 200 ms
13,652 KB
testcase_18 AC 168 ms
13,016 KB
testcase_19 AC 252 ms
14,808 KB
testcase_20 AC 88 ms
8,272 KB
testcase_21 AC 243 ms
14,424 KB
testcase_22 AC 123 ms
8,912 KB
testcase_23 AC 127 ms
9,048 KB
testcase_24 AC 332 ms
23,132 KB
testcase_25 AC 331 ms
23,132 KB
testcase_26 AC 332 ms
23,132 KB
testcase_27 AC 326 ms
23,260 KB
testcase_28 AC 333 ms
23,260 KB
testcase_29 AC 331 ms
23,256 KB
testcase_30 AC 329 ms
23,132 KB
testcase_31 AC 334 ms
23,136 KB
testcase_32 AC 333 ms
23,264 KB
testcase_33 AC 328 ms
23,136 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 225 ms
23,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> P(N);
  for (int i = 0; i < N; i++){
    cin >> P[i];
  }
  vector<int> a(N), b(N);
  for (int i = 0; i < N; i++){
    cin >> a[i] >> b[i];
  }
  vector<int> c(M), d(M);
  for (int i = 0; i < M; i++){
    cin >> c[i] >> d[i];
  }
  int ans = 0;
  for (int i = 0; i < 2; i++){
    for (int j = 0; j < 2; j++){
      vector<tuple<int, int, int>> S;
      for (int k = 0; k < M; k++){
        for (int l = 0; l < N; l++){
          int x;
          if (i == 0){
            x = a[l] - c[k];
          } else {
            x = a[l] + c[k];
          }
          int y;
          if (j == 0){
            y = b[l] - d[k];
          } else {
            y  = b[l] + d[k];
          }
          S.push_back(make_tuple(x, y, P[l]));
        }
      }
      sort(S.begin(), S.end());
      int sum = 0;
      for (int k = 0; k < N * M; k++){
        sum += get<2>(S[k]);
        if (k == N * M - 1){
          ans = max(ans, sum);
        } else if (get<0>(S[k]) != get<0>(S[k + 1]) || get<1>(S[k]) != get<1>(S[k + 1])){
          ans = max(ans, sum);
          sum = 0;
        }
      }
    }
  }
  cout << ans << endl;
}
0