結果

問題 No.2999 Long Long Friedrice
ユーザー friedrice
提出日時 2024-12-11 22:50:48
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,170 bytes
コンパイル時間 5,196 ms
コンパイル使用メモリ 314,616 KB
実行使用メモリ 17,096 KB
最終ジャッジ日時 2024-12-23 23:31:26
合計ジャッジ時間 52,996 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 18 TLE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using mint = atcoder::modint998244353;
using maxt = atcoder::modint1000000007;
vector<ll> Era(int N) {
  vector<ll> ans(0, 0);
  vector<bool> isprime(N + 1, true);
  isprime.at(1) = false;
  for(int i = 1; i <= N; i++) {
    if(isprime.at(i)) {
      ans.push_back(i);
      for(int j = 2 * i; j <= N; j += i) {
        isprime.at(j) = false;
      }
    }
  }
  return ans;
}
ll POW(ll a, int N) {
  if(N == 1) {
    return a;
  }
  ll ans = POW(a, N / 2) * POW(a, N / 2);
  if(N % 2 == 1) {
    ans *= a;
  }
  return ans;
}
//ライブラリここまで

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> in(N);
	for(pair<int, int> &o : in) {
		cin >> o.first;
	}
	for(pair<int, int> &o : in) {
		cin >> o.second;
	}
	int64_t tmp = 1;
	for(int64_t i = 1; i <= N; i++) {
	  tmp *= i;
	}
	int ans = 0;
	while(tmp > 0) {
	  int H = 1;
	  for(int i = 0; i < N; i++) {
	    if(H == in.at(i).first) {
	      H += in.at(i).second;
	    }
	  }
	  ans = max(ans, H);
	  tmp--;
	  next_permutation(in.begin(), in.end());
	}
	cout << ans << endl;
}
0