結果

問題 No.1862 Copy and Paste
ユーザー SSRSSSRS
提出日時 2022-03-04 23:13:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 206,996 KB
実行使用メモリ 9,348 KB
最終ジャッジ日時 2023-09-26 02:28:32
合計ジャッジ時間 6,039 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
9,308 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,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000;
vector<pair<int, pair<int, int>>> quotient_ranges(int N){
	vector<pair<int, pair<int, int>>> ans;
	for (int i = 1; i * i <= N; i++){
		ans.push_back(make_pair(N / i, make_pair(i, i)));
	}
	for (int i = N / ((int) sqrt(N) + 1); i >= 1; i--){
		ans.push_back(make_pair(i, make_pair(N / (i + 1) + 1, N / i)));
	}
	return ans;
}
int main(){
  int A, B;
  cin >> A >> B;
  int N;
  cin >> N;
  vector<pair<int, pair<int, int>>> Q = quotient_ranges(N);
  int M = Q.size();
  vector<long long> X(M);
  for (int i = 0; i < M; i++){
    X[i] = Q[i].first;
  }
  reverse(X.begin(), X.end());
  vector<long long> dp(M, INF);
  dp[0] = 0;
  for (int i = 0; i < M; i++){
    int p = lower_bound(X.begin(), X.end(), X[i] * 2) - X.begin();
    for (int j = p; j < M; j++){
      dp[j] = min(dp[j], dp[i] + A + (X[j] - 1) / X[i] * B);
    }
  }
  cout << dp[M - 1] << endl;
}
0