SuitNdtie

Blowblock

May 1st, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<vector>
  3. #include<algorithm>
  4. using namespace std;
  5. typedef long long int ll;
  6. int main(){
  7.     int n;
  8.     scanf("%d",&n);
  9.     vector<ll> A;
  10.     vector<ll> B;
  11.     vector<ll> C;
  12.     vector<ll> D;
  13.     for(int i = 0 ; i < n ; i ++){
  14.         for(int j = 0 ; j < n ; j ++){
  15.             ll x;
  16.             scanf("%lld",&x);
  17.             if(i%2 == 0){
  18.                 if(j%2 == 0){
  19.                     A.push_back(x);
  20.                 }else{
  21.                     B.push_back(x);
  22.                 }
  23.             }else{
  24.                 if(j%2 == 0){
  25.                     C.push_back(x);
  26.                 }else{
  27.                     D.push_back(x);
  28.                 }
  29.             }
  30.         }
  31.     }
  32.     sort(A.begin(),A.end());
  33.     sort(B.begin(),B.end());
  34.     sort(C.begin(),C.end());
  35.     sort(D.begin(),D.end());
  36.     ll ans = 0;
  37.     while(!A.empty()){
  38.         ans += (A[A.size()-1]*B[B.size()-1]*C[C.size()-1]*D[D.size()-1]);
  39.         A.pop_back();
  40.         B.pop_back();
  41.         C.pop_back();
  42.         D.pop_back();
  43.     }
  44.     printf("%lld",ans);
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment