結果

問題 No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
ユーザー 👑 hitonanodehitonanode
提出日時 2021-10-29 22:35:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 287 ms / 3,000 ms
コード長 1,411 bytes
コンパイル時間 1,882 ms
コンパイル使用メモリ 122,200 KB
実行使用メモリ 10,840 KB
最終ジャッジ日時 2024-04-27 03:59:23
合計ジャッジ時間 7,464 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 58 ms
6,944 KB
testcase_15 AC 168 ms
7,600 KB
testcase_16 AC 239 ms
9,244 KB
testcase_17 AC 165 ms
7,436 KB
testcase_18 AC 133 ms
6,940 KB
testcase_19 AC 210 ms
8,552 KB
testcase_20 AC 69 ms
6,944 KB
testcase_21 AC 198 ms
8,136 KB
testcase_22 AC 98 ms
6,944 KB
testcase_23 AC 105 ms
6,940 KB
testcase_24 AC 282 ms
10,632 KB
testcase_25 AC 279 ms
10,792 KB
testcase_26 AC 287 ms
10,744 KB
testcase_27 AC 282 ms
10,632 KB
testcase_28 AC 284 ms
10,808 KB
testcase_29 AC 279 ms
10,768 KB
testcase_30 AC 280 ms
10,564 KB
testcase_31 AC 279 ms
10,840 KB
testcase_32 AC 277 ms
10,692 KB
testcase_33 AC 284 ms
10,732 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 1 ms
6,940 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 151 ms
10,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using pint = pair<int, int>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template <typename T> bool chmax(T &m, const T q) { return m < q ? (m = q, true) : false; }
template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }


int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    for (auto &x : P) cin >> x;
    vector<pint> AB(N), CD(M);
    for (auto &[x, y] : AB) cin >> x >> y;
    for (auto &[x, y] : CD) cin >> x >> y;

    int ret = 0;

    vector<pair<pint, int>> vs(N * M);
    REP(t, 2) {
        REP(tt, 2) {
            REP(i, N) REP(j, M) {
                vs[i * M + j] = {CD[j] - AB[i], P[i]};
            }
            sort(vs.begin(), vs.end());
            int c = 0;
            REP(k, vs.size()) {
                c += vs[k].second;
                chmax(ret, c);
                if (k + 1 < int(vs.size()) and vs[k].first != vs[k + 1].first) c = 0;
            }

            REP(i, N) AB[i].second *= -1;
        }
        REP(i, N) AB[i].first *= -1;
    }
    cout << ret << '\n';
}
0