結果

問題 No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
ユーザー tassei903tassei903
提出日時 2021-10-29 23:23:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,749 ms / 3,000 ms
コード長 2,625 bytes
コンパイル時間 1,098 ms
コンパイル使用メモリ 99,600 KB
実行使用メモリ 43,728 KB
最終ジャッジ日時 2023-08-24 15:32:31
合計ジャッジ時間 43,883 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 294 ms
12,028 KB
testcase_15 AC 1,620 ms
26,808 KB
testcase_16 AC 2,385 ms
35,028 KB
testcase_17 AC 1,587 ms
26,112 KB
testcase_18 AC 937 ms
21,920 KB
testcase_19 AC 1,814 ms
31,944 KB
testcase_20 AC 381 ms
13,604 KB
testcase_21 AC 1,797 ms
30,176 KB
testcase_22 AC 651 ms
17,568 KB
testcase_23 AC 719 ms
18,268 KB
testcase_24 AC 2,715 ms
43,520 KB
testcase_25 AC 2,720 ms
43,448 KB
testcase_26 AC 2,666 ms
43,524 KB
testcase_27 AC 2,725 ms
43,388 KB
testcase_28 AC 2,749 ms
43,516 KB
testcase_29 AC 2,685 ms
43,676 KB
testcase_30 AC 2,745 ms
43,412 KB
testcase_31 AC 2,697 ms
43,460 KB
testcase_32 AC 2,705 ms
43,728 KB
testcase_33 AC 2,711 ms
43,408 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 140 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <set>
#include <queue>
#include <tuple>
#include <map>
#define se second
#define fi first
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define rep(i,n) for(long long i = 0; i < (int)n; i++)

#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;


void print(V<ll> ar) {
    for(auto x: ar)cout << x << " " ;
    cout << endl;
}

ll gcd(ll a, ll b) {
    if (a<b)return gcd(b,a);
    if (b==0)return a;
    return gcd(b, a%b);
}

ll mpow(ll x, ll n, ll p) {
    ll r = 1;
    while (n>0) {
        if (n%2) {
            r*=x;
            r%=p;
        }
        x *= x;
        x %= p;
        n/=2;
    }
    return r;
}
const ll mod = 998244353;

V<P<ll,int>> facts(ll n) {
    V<P<ll,int>> res;
    if (n==1)return res;

    for(int x = 2; x*x<=n; x++) {
        if (n%x==0) {
            int p = 0;
            while (n%x==0) {
                p+=1;
                n/=x;
            }
            res.emplace_back(P<ll,int>(x, p));
        }
    }
    if (n!=1) {
        res.emplace_back(P<ll,int>(n, 1));
    }
    return res;
}



int main()
{
    int n,m;cin >> n >> m;
    V<ll> p(n);rep(i, n)cin >> p[i];
    V<ll> a(n),b(n),c(m),d(m);
    rep(i, n)cin >> a[i] >> b[i];
    rep(i, m)cin >> c[i] >> d[i];
    ll ans = 0;
    map<P<ll, ll>, ll> mp;
    rep(i, n)rep(j, m) {
        mp[P<ll,ll>(a[i]-c[j], b[i]-d[j])] += p[i];
    }
    for(auto x = mp.begin(); x!=mp.end() ; x++) {
        ans = max(ans, x->second);
    }
    rep(i, n) {
        a[i] = -a[i];
    }
    mp = map<P<ll,ll>,ll>();
    rep(i, n)rep(j, m) {
        mp[P<ll,ll>(a[i]-c[j], b[i]-d[j])] += p[i];
    }
    for(auto x = mp.begin(); x!=mp.end() ; x++) {
        ans = max(ans, x->second);
    }
    rep(i, n) {
        b[i] = -b[i];
    }
    mp = map<P<ll,ll>,ll>();
    rep(i, n)rep(j, m) {
        mp[P<ll,ll>(a[i]-c[j], b[i]-d[j])] += p[i];
    }
    for(auto x = mp.begin(); x!=mp.end() ; x++) {
        ans = max(ans, x->second);
    }
    rep(i, n) {
        a[i] = -a[i];
    }
    mp = map<P<ll,ll>,ll>();
    rep(i, n)rep(j, m) {
        mp[P<ll,ll>(a[i]-c[j], b[i]-d[j])] += p[i];
    }
    for(auto x = mp.begin(); x!=mp.end() ; x++) {
        ans = max(ans, x->second);
    }
    cout << ans << endl;
    
}
0