結果
| 問題 | 
                            No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
                             | 
                    
| コンテスト | |
| ユーザー | 
                             milanis48663220
                         | 
                    
| 提出日時 | 2021-10-29 22:01:28 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,475 ms / 3,000 ms | 
| コード長 | 2,437 bytes | 
| コンパイル時間 | 1,703 ms | 
| コンパイル使用メモリ | 125,408 KB | 
| 最終ジャッジ日時 | 2025-01-25 08:54:24 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 39 | 
ソースコード
#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;
}
            
            
            
        
            
milanis48663220