Submission #19272586


Source Code Expand

Copy
#include <iostream>
#include <queue>
#include <functional>
// #include <cstdint>

struct MachineState {
  int64_t cur_cost;
  int64_t increase;
};

bool operator>(const MachineState &state1, const MachineState &state2) {
  return state1.cur_cost > state2.cur_cost;
}

int main() {
  int64_t cur_cost, increase;
  size_t n_machine, n_present;
  std::cin >> n_machine >> n_present;

  std::priority_queue<MachineState, std::vector<MachineState>, std::greater<MachineState>> queue;
  for (size_t i = 0; i < n_machine; i++) {
    std::cin >> cur_cost >> increase;
    queue.push(MachineState{cur_cost, increase});
  }

  int64_t time = 0;
  for (size_t i = 0; i < n_present; i++) {
    MachineState state = queue.top();
    queue.pop();

    time += state.cur_cost;
    queue.push(MachineState{state.cur_cost + state.increase, state.increase});
  }

  std::cout << time << std::endl;
}

Submission Info

Submission Time
Task C - Factory
User moyashi97
Language C++ (Clang 10.0.0)
Score 300
Code Size 918 Byte
Status AC
Exec Time 171 ms
Memory 4892 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 21
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt AC 11 ms 3156 KB
sample_02.txt AC 6 ms 3188 KB
sample_03.txt AC 2 ms 3144 KB
subtask_1_1.txt AC 2 ms 3156 KB
subtask_1_10.txt AC 77 ms 3772 KB
subtask_1_11.txt AC 3 ms 3096 KB
subtask_1_12.txt AC 138 ms 4824 KB
subtask_1_13.txt AC 2 ms 3112 KB
subtask_1_14.txt AC 52 ms 3220 KB
subtask_1_15.txt AC 143 ms 4816 KB
subtask_1_16.txt AC 4 ms 3024 KB
subtask_1_17.txt AC 2 ms 3140 KB
subtask_1_18.txt AC 148 ms 4820 KB
subtask_1_2.txt AC 34 ms 3140 KB
subtask_1_3.txt AC 86 ms 3664 KB
subtask_1_4.txt AC 16 ms 3176 KB
subtask_1_5.txt AC 160 ms 4664 KB
subtask_1_6.txt AC 24 ms 3152 KB
subtask_1_7.txt AC 8 ms 3144 KB
subtask_1_8.txt AC 171 ms 4664 KB
subtask_1_9.txt AC 158 ms 4892 KB