Submission #19272604


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++ (GCC 9.2.1)
Score 300
Code Size 916 Byte
Status AC
Exec Time 82 ms
Memory 5340 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 9 ms 3384 KB
sample_02.txt AC 8 ms 3384 KB
sample_03.txt AC 3 ms 3432 KB
subtask_1_1.txt AC 2 ms 3484 KB
subtask_1_10.txt AC 49 ms 4124 KB
subtask_1_11.txt AC 2 ms 3524 KB
subtask_1_12.txt AC 57 ms 5168 KB
subtask_1_13.txt AC 2 ms 3512 KB
subtask_1_14.txt AC 27 ms 3668 KB
subtask_1_15.txt AC 70 ms 5340 KB
subtask_1_16.txt AC 5 ms 3380 KB
subtask_1_17.txt AC 2 ms 3380 KB
subtask_1_18.txt AC 73 ms 5108 KB
subtask_1_2.txt AC 27 ms 3528 KB
subtask_1_3.txt AC 41 ms 4192 KB
subtask_1_4.txt AC 14 ms 3460 KB
subtask_1_5.txt AC 70 ms 5336 KB
subtask_1_6.txt AC 19 ms 3688 KB
subtask_1_7.txt AC 7 ms 3600 KB
subtask_1_8.txt AC 82 ms 5168 KB
subtask_1_9.txt AC 74 ms 5160 KB