結果

問題 No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
ユーザー milanis48663220milanis48663220
提出日時 2021-10-29 22:01:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,884 ms / 3,000 ms
コード長 2,437 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 129,516 KB
実行使用メモリ 39,224 KB
最終ジャッジ日時 2024-04-16 14:53:47
合計ジャッジ時間 29,697 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 4 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 3 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 3 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 199 ms
11,216 KB
testcase_15 AC 1,144 ms
28,216 KB
testcase_16 AC 1,530 ms
32,944 KB
testcase_17 AC 1,122 ms
28,056 KB
testcase_18 AC 672 ms
19,988 KB
testcase_19 AC 1,312 ms
30,240 KB
testcase_20 AC 246 ms
12,388 KB
testcase_21 AC 1,242 ms
28,840 KB
testcase_22 AC 491 ms
16,760 KB
testcase_23 AC 530 ms
17,508 KB
testcase_24 AC 1,832 ms
39,084 KB
testcase_25 AC 1,884 ms
38,964 KB
testcase_26 AC 1,839 ms
39,080 KB
testcase_27 AC 1,866 ms
39,164 KB
testcase_28 AC 1,853 ms
39,096 KB
testcase_29 AC 1,869 ms
39,052 KB
testcase_30 AC 1,845 ms
39,224 KB
testcase_31 AC 1,848 ms
38,948 KB
testcase_32 AC 1,874 ms
38,972 KB
testcase_33 AC 1,824 ms
39,128 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 112 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;
using P = pair<int, int>;


struct HashPair {

    template<class T1, class T2>
    size_t operator()(const pair<T1, T2> &p) const {

        auto hash1 = hash<T1>{}(p.first);

        auto hash2 = hash<T2>{}(p.second);

        size_t seed = 0;
        seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        return seed;
    }
};

ll calc(vector<int> a, vector<int> b, vector<int> c, vector<int> d, vector<ll> p){
    int n = a.size(), m = c.size();
    unordered_map<P, ll, HashPair> mp;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            int dx = c[j]-a[i];
            int dy = d[j]-b[i];
            // if(dx%2 == 0 && dy%2 == 0){
                auto pt = P(dx, dy);
                if(mp.count(pt)){
                    mp[pt] += p[i];
                }else{
                    mp[pt] = p[i];
                }
            // }
        }
    }
    ll ans = 0;
    for(auto [p, x]: mp) {
        chmax(ans, x);
        // cout << p.first << ", " << p.second << ": " << x << endl;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, m; cin >> n >> m;
    vector<ll> p(n);
    vector<int> a(n), b(n), c(m), d(m);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for(int i = 0; i < m; i++) cin >> c[i] >> d[i];
    ll ans = calc(a, b, c, d, p);
    for(int i = 0; i < n; i++) a[i] *= -1;
    chmax(ans, calc(a, b, c, d, p));
    for(int i = 0; i < n; i++) a[i] *= -1;
    for(int i = 0; i < n; i++) b[i] *= -1;
    chmax(ans, calc(a, b, c, d, p));
    for(int i = 0; i < n; i++) a[i] *= -1;
    chmax(ans, calc(a, b, c, d, p));
    cout << ans << endl;
}
0