結果

問題 No.1564 Sum of Products of Pairs
ユーザー ytqm3ytqm3
提出日時 2021-06-26 14:08:09
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,851 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 203,336 KB
実行使用メモリ 4,736 KB
最終ジャッジ日時 2023-09-07 16:37:59
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 32 ms
4,380 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 42 ms
4,376 KB
testcase_06 AC 31 ms
4,380 KB
testcase_07 AC 20 ms
4,384 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 45 ms
4,376 KB
testcase_11 AC 49 ms
4,376 KB
testcase_12 AC 33 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 66 ms
4,736 KB
testcase_19 AC 63 ms
4,464 KB
testcase_20 AC 67 ms
4,680 KB
testcase_21 AC 68 ms
4,696 KB
testcase_22 AC 61 ms
4,440 KB
testcase_23 AC 68 ms
4,580 KB
testcase_24 AC 68 ms
4,704 KB
testcase_25 AC 68 ms
4,592 KB
testcase_26 AC 68 ms
4,608 KB
testcase_27 AC 68 ms
4,692 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,388 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
typedef long double f128;
using namespace std;

template<typename T>
void scan(T& n){
  cin>>n;
}

void scan(){}

template<typename T,class... Args>
void scan(T& n,Args&... args){
  scan(n);
  scan(args...);
}

template<typename T>
void scanall(T start,T end){
  for(;start!=end;++start){
    scan(*start);
  }
}

template<typename T>
void print(T n){
  cout<<n;
}

void print(){}

template<typename T,class... Args>
void print(T n,Args... args){
  print(n);
  print(args...);
}

template<typename T>
void println(T n){
  print(n);
  cout<<endl;
}

template<typename T,class... Args>
void println(T n,Args... args){
  print(n,' ');
  println(args...);
}

template<typename T>
void printall(T start,T end){
  if(start!=end){
    print(*start);
    for(++start;start!=end;++start){
      print(' ',*start);
    }
  }
  cout<<endl;
}

template<typename T>
void chmax(T& n,T m){
  n=max(n,m);
}

template<typename T>
void chmin(T& n,T m){
  n=min(n,m);
}

template<typename T,typename U>
T power(T a,U n){
  T res=1;
  while(n){
    res*=(n&1)?a:1;
    a*=a;
    n>>=1;
  }
  return res;
}

template<typename T>
struct combination{
  vector<T> fact;
  combination(const int Max=3000000):fact(Max+1,1){
    for(int i=2;i<=Max;++i){
      fact[i]=fact[i-1]*i;
    }
  }
  template<typename U>
  T nCk(U n,U k){
    if(n<k||n<0||k<0){
      return 0;
    }
    return fact[n]/fact[k]/fact[n-k];
  }
};

void solve();

int main(){
  cout<<fixed<<setprecision(15);
  bool is_multicase=false;
  int T=1;
  if(is_multicase){
    scan(T);
  }
  for(int i=0;i<T;++i){
    solve();
  }
  return 0;
}

void solve(){
  int N;
  scan(N);
  vector<i64> A(2*N);
  scanall(A.begin(),A.end());
  sort(A.begin(),A.end());
  i64 ans=0;
  for(int i=0;i<N;++i){
    ans+=A[2*i]*A[2*i+1];
  }
  println(ans);
}
0