Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<vector>
- #include<algorithm>
- using namespace std;
- typedef long long int ll;
- int main(){
- int n;
- scanf("%d",&n);
- vector<ll> A;
- vector<ll> B;
- vector<ll> C;
- vector<ll> D;
- for(int i = 0 ; i < n ; i ++){
- for(int j = 0 ; j < n ; j ++){
- ll x;
- scanf("%lld",&x);
- if(i%2 == 0){
- if(j%2 == 0){
- A.push_back(x);
- }else{
- B.push_back(x);
- }
- }else{
- if(j%2 == 0){
- C.push_back(x);
- }else{
- D.push_back(x);
- }
- }
- }
- }
- sort(A.begin(),A.end());
- sort(B.begin(),B.end());
- sort(C.begin(),C.end());
- sort(D.begin(),D.end());
- ll ans = 0;
- while(!A.empty()){
- ans += (A[A.size()-1]*B[B.size()-1]*C[C.size()-1]*D[D.size()-1]);
- A.pop_back();
- B.pop_back();
- C.pop_back();
- D.pop_back();
- }
- printf("%lld",ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment