結果

問題 No.270 next_permutation (1)
ユーザー y_mazuny_mazun
提出日時 2015-08-21 23:10:12
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 554 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 49,740 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-25 15:22:49
合計ジャッジ時間 4,777 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 AC 501 ms
4,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdlib>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

typedef long long ll;

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const int k = getInt();

  vector<int> p(n);
  vector<int> b(n);
  ll a = 0;

  REP(i,n) p[i] = getInt();
  REP(i,n) b[i] = getInt();

  REP(i,k){
    REP(j,n) a += std::abs(p[j] - b[j]);
    next_permutation(p.begin(), p.end());
  }

  printf("%lld\n", a);
  return 0;
}
0