#include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) struct Pos2{ int x,y; }; bool operator<(Pos2 l, Pos2 r){ if(l.x != r.x) return l.x < r.x; return l.y < r.y; } Pos2 operator-(Pos2 l, Pos2 r){ return { l.x - r.x, l.y - r.y }; } int main(){ int num_cup; cin >> num_cup; int num_ball; cin >> num_ball; vector score_cup(num_cup); for(auto& a : score_cup) cin >> a; vector pos_cup(num_cup); for(auto& a : pos_cup) cin >> a.x >> a.y; vector pos_ball(num_ball); for(auto& a : pos_ball) cin >> a.x >> a.y; map score_table[2][2]; // reversed or not for x,y for(int cupi = 0; cupi < num_cup; cupi++){ for(int balli = 0; balli < num_ball; balli++){ for(int x_reversed : { 0, 1 }){ for(int y_reversed : { 0, 1 }){ //cout << x_reversed << ", " << y_reversed << ", " //<< (pos_ball[balli] - pos_cup[cupi]).x << ", " //<< (pos_ball[balli] - pos_cup[cupi]).y << " : " << score_cup[cupi] << endl; score_table[x_reversed][y_reversed][pos_ball[balli] - pos_cup[cupi]] += score_cup[cupi]; pos_ball[balli].y *= -1; } pos_ball[balli].x *= -1; } } } int ans = 0; for(int x_reversed : { 0, 1 }){ for(int y_reversed : { 0, 1 }){ for(auto a : score_table[x_reversed][y_reversed]){ ans = max(ans, a.second); } } } cout << ans << "\n"; return 0; } struct ios_do_not_sync { ios_do_not_sync() { ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;