結果

問題 No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
ユーザー 沙耶花沙耶花
提出日時 2021-10-29 22:17:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 806 ms / 3,000 ms
コード長 1,163 bytes
コンパイル時間 4,776 ms
コンパイル使用メモリ 262,124 KB
実行使用メモリ 16,752 KB
最終ジャッジ日時 2024-04-16 15:07:50
合計ジャッジ時間 18,058 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 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 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 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 149 ms
6,624 KB
testcase_15 AC 457 ms
10,464 KB
testcase_16 AC 655 ms
11,376 KB
testcase_17 AC 444 ms
10,468 KB
testcase_18 AC 358 ms
9,956 KB
testcase_19 AC 572 ms
10,852 KB
testcase_20 AC 178 ms
6,872 KB
testcase_21 AC 535 ms
10,724 KB
testcase_22 AC 260 ms
7,132 KB
testcase_23 AC 268 ms
7,264 KB
testcase_24 AC 803 ms
16,620 KB
testcase_25 AC 796 ms
16,492 KB
testcase_26 AC 794 ms
16,744 KB
testcase_27 AC 789 ms
16,488 KB
testcase_28 AC 805 ms
16,492 KB
testcase_29 AC 806 ms
16,492 KB
testcase_30 AC 800 ms
16,752 KB
testcase_31 AC 801 ms
16,620 KB
testcase_32 AC 804 ms
16,532 KB
testcase_33 AC 805 ms
16,748 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 295 ms
16,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf (long long)1000000000000000000
int n,m;
vector<long long> p;

long long get(vector<int> a,vector<int> b,vector<int> c,vector<int> d){
	vector<pair<int,int>> ps;
	rep(i,n){
		rep(j,m){
			ps.emplace_back(c[j]-a[i],d[j]-b[i]);
			//mp[make_pair(c[j]-a[i],d[j]-b[i])] += p[i];
		}
	}
	sort(ps.begin(),ps.end());
	ps.erase(unique(ps.begin(),ps.end()),ps.end());
	vector<long long> maxi(ps.size(),0LL);
	rep(i,n){
		rep(j,m){
			pair<int,int> temp(c[j]-a[i],d[j]-b[i]);
			int d = distance(ps.begin(),lower_bound(ps.begin(),ps.end(),temp));
			maxi[d] += p[i];
		}
	}
	long long ret = 0LL;
	rep(i,maxi.size())ret=  max(ret,maxi[i]);
	return ret;
}

int main(){
	
	cin>>n>>m;
	
	p.resize(n);
	rep(i,n)cin>>p[i];
	
	vector<int> a(n),b(n),c(m),d(m);
	rep(i,n)cin>>a[i]>>b[i];
	rep(i,m)cin>>c[i]>>d[i];
	
	long long ans = 0LL;
	
	rep(i,2){
		rep(j,2){
			ans = max(ans,get(a,b,c,d));
			rep(k,m)c[k] *= -1;
		}
		rep(k,m)d[k] *= -1;
	}
	cout<<ans<<endl;
	
	return 0;
	
}
0