Submission #46985162


Source Code Expand

#include <bits/stdc++.h>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...)
#endif
using int64 = long long;
using uint = unsigned int;
using uint64 = unsigned long long;
bool ckmin(auto& a, auto b) { return b < a ? a = b, 1 : 0; }
bool ckmax(auto& a, auto b) { return b > a ? a = b, 1 : 0; }
using namespace std;

const int64 inf = 1e14;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int64> D(n);
  for (int i = 0; i < n; i++) cin >> D[i];
  int64 L1, C1, K1, L2, C2, K2;
  cin >> L1 >> C1 >> K1 >> L2 >> C2 >> K2;

  vector dp(n + 1, vector<int64>(K1 + 1, inf));
  dp[n][0] = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j <= K1; j++) {
      for (int k = 0; k <= j; k++) {
        int64 len = max(0ll, D[i] - (j - k) * L1);
        int64 need = len / L2 + (len % L2 == 0 ? 0 : 1);
        ckmin(dp[i][j], dp[i + 1][k] + need);
      }
    }
  }
  int64 ans = inf;
  for (int j = 0; j <= K1; j++) {
    if (dp[0][j] <= K2) {
      ckmin(ans, j * C1 + dp[0][j] * C2);
    }
  }
  if (ans > 1e13) ans = -1;
  cout << ans << '\n';

  return 0;
}

Submission Info

Submission Time
Task F - Sensor Optimization Dilemma
User xindubawukong
Language C++ 20 (gcc 12.2)
Score 500
Code Size 1163 Byte
Status AC
Exec Time 147 ms
Memory 3896 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 60
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 03_handmade_00.txt, 03_handmade_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3428 KiB
00_sample_01.txt AC 1 ms 3500 KiB
00_sample_02.txt AC 1 ms 3432 KiB
01_random_00.txt AC 75 ms 3616 KiB
01_random_01.txt AC 142 ms 3884 KiB
01_random_02.txt AC 82 ms 3748 KiB
01_random_03.txt AC 110 ms 3820 KiB
01_random_04.txt AC 141 ms 3896 KiB
01_random_05.txt AC 144 ms 3892 KiB
01_random_06.txt AC 127 ms 3816 KiB
01_random_07.txt AC 50 ms 3620 KiB
01_random_08.txt AC 103 ms 3788 KiB
01_random_09.txt AC 99 ms 3880 KiB
01_random_10.txt AC 89 ms 3620 KiB
01_random_11.txt AC 52 ms 3616 KiB
01_random_12.txt AC 68 ms 3728 KiB
01_random_13.txt AC 43 ms 3688 KiB
01_random_14.txt AC 21 ms 3532 KiB
01_random_15.txt AC 6 ms 3624 KiB
01_random_16.txt AC 32 ms 3572 KiB
01_random_17.txt AC 74 ms 3684 KiB
01_random_18.txt AC 61 ms 3592 KiB
01_random_19.txt AC 145 ms 3752 KiB
01_random_20.txt AC 28 ms 3500 KiB
01_random_21.txt AC 79 ms 3568 KiB
01_random_22.txt AC 42 ms 3620 KiB
01_random_23.txt AC 5 ms 3744 KiB
01_random_24.txt AC 143 ms 3832 KiB
01_random_25.txt AC 68 ms 3740 KiB
01_random_26.txt AC 88 ms 3576 KiB
01_random_27.txt AC 88 ms 3728 KiB
01_random_28.txt AC 95 ms 3884 KiB
01_random_29.txt AC 62 ms 3744 KiB
01_random_30.txt AC 144 ms 3792 KiB
01_random_31.txt AC 82 ms 3552 KiB
01_random_32.txt AC 146 ms 3840 KiB
01_random_33.txt AC 146 ms 3828 KiB
01_random_34.txt AC 146 ms 3888 KiB
01_random_35.txt AC 144 ms 3812 KiB
01_random_36.txt AC 135 ms 3824 KiB
01_random_37.txt AC 140 ms 3888 KiB
01_random_38.txt AC 143 ms 3848 KiB
01_random_39.txt AC 147 ms 3868 KiB
01_random_40.txt AC 13 ms 3564 KiB
01_random_41.txt AC 145 ms 3884 KiB
01_random_42.txt AC 15 ms 3568 KiB
01_random_43.txt AC 24 ms 3592 KiB
01_random_44.txt AC 43 ms 3628 KiB
02_random2_00.txt AC 15 ms 3576 KiB
02_random2_01.txt AC 2 ms 3428 KiB
02_random2_02.txt AC 4 ms 3468 KiB
02_random2_03.txt AC 2 ms 3560 KiB
02_random2_04.txt AC 3 ms 3452 KiB
02_random2_05.txt AC 4 ms 3480 KiB
02_random2_06.txt AC 2 ms 3564 KiB
02_random2_07.txt AC 1 ms 3504 KiB
02_random2_08.txt AC 1 ms 3584 KiB
02_random2_09.txt AC 2 ms 3452 KiB
03_handmade_00.txt AC 1 ms 3540 KiB
03_handmade_01.txt AC 2 ms 3456 KiB