結果

問題 No.798 コレクション
ユーザー ikdikd
提出日時 2018-08-05 00:44:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 555 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 72,316 KB
実行使用メモリ 7,684 KB
最終ジャッジ日時 2023-09-11 02:24:14
合計ジャッジ時間 4,530 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,684 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 48 ms
4,380 KB
testcase_10 AC 48 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

int main(){

  int n; cin>> n;
  vector<int> a(n), b(n);
  rep(i, n) cin>> a[i]>> b[i];

  vector<int> perm(n);
  iota(perm.begin(), perm.end(), 0);
  int mn=1e9;
  do{
    int sum=0;
    for(int j=0, _i=0; _i<n; j++){
      auto i=perm[_i];
      sum+=a[i]+b[i]*j;
      _i++;
      if(j%2==1) _i++;  
    }
    mn=min(mn, sum);
  }while(next_permutation(perm.begin(), perm.end()));

  cout<< mn<< endl;
  return 0;
}
0