結果

問題 No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
ユーザー 👑 hitonanodehitonanode
提出日時 2021-10-29 22:33:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 329 ms / 3,000 ms
コード長 1,511 bytes
コンパイル時間 1,485 ms
コンパイル使用メモリ 114,704 KB
実行使用メモリ 24,964 KB
最終ジャッジ日時 2024-04-16 15:24:33
合計ジャッジ時間 8,100 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 69 ms
7,920 KB
testcase_15 AC 194 ms
13,836 KB
testcase_16 AC 265 ms
15,192 KB
testcase_17 AC 189 ms
14,392 KB
testcase_18 AC 158 ms
14,384 KB
testcase_19 AC 237 ms
15,208 KB
testcase_20 AC 82 ms
9,068 KB
testcase_21 AC 224 ms
14,400 KB
testcase_22 AC 114 ms
8,936 KB
testcase_23 AC 119 ms
8,936 KB
testcase_24 AC 325 ms
23,180 KB
testcase_25 AC 320 ms
24,900 KB
testcase_26 AC 323 ms
23,296 KB
testcase_27 AC 325 ms
23,960 KB
testcase_28 AC 324 ms
23,204 KB
testcase_29 AC 323 ms
23,148 KB
testcase_30 AC 326 ms
24,964 KB
testcase_31 AC 326 ms
23,752 KB
testcase_32 AC 327 ms
24,468 KB
testcase_33 AC 329 ms
24,100 KB
testcase_34 AC 3 ms
6,940 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 201 ms
23,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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); }
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;

    REP(t, 2) {
        REP(tt, 2) {
            vector<pair<pint, int>> vs;
            REP(i, N) REP(j, M) {
                vs.emplace_back(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