Submission #69370920
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
/////////////////// メイン ///////////////////
int main () {
//////////////////// 入力 ////////////////////
int n, k;
cin >> n >> k;
vector<long long> a(n);
vector<int> b(n), c(n);
for (int i=0; i<n; i++) {
cin >> a.at(i) >> b.at(i) >> c.at(i);
}
//////////////// 出力変数定義 ////////////////
vector<long long> result(n,0);
//////////////////// 処理 ////////////////////
// 店内の客の数
int num = 0;
// 現在時刻
long long time = 0;
// 退出予定一覧
priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> que;
// 早く来た客から順に処理
for (int i=0; i<n; i++) {
// 空き席数が足りなければ、空くまで待つ
while (c.at(i)+num>k) {
time = max(time,que.top().first);
num -= que.top().second;
que.pop();
}
// まだ客が到着していなければ、到着を待つ
time = max(time,a.at(i));
// 入店時刻を記録
result.at(i) = time;
// 客数と退出予定の更新
num += c.at(i);
que.emplace(time+b.at(i),c.at(i));
}
//////////////////// 出力 ////////////////////
for (size_t i=0; i<result.size(); i++) {
cout << result.at(i) << endl;
}
//////////////////// 終了 ////////////////////
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Long Waiting |
| User | wightou |
| Language | C++ 23 (gcc 12.2) |
| Score | 400 |
| Code Size | 1444 Byte |
| Status | AC |
| Exec Time | 459 ms |
| Memory | 14284 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 1 ms | 3496 KiB |
| 00-sample-02.txt | AC | 1 ms | 3560 KiB |
| 00-sample-03.txt | AC | 1 ms | 3464 KiB |
| 01-01.txt | AC | 146 ms | 5200 KiB |
| 01-02.txt | AC | 459 ms | 11304 KiB |
| 01-03.txt | AC | 166 ms | 5724 KiB |
| 01-04.txt | AC | 158 ms | 5440 KiB |
| 01-05.txt | AC | 444 ms | 14276 KiB |
| 01-06.txt | AC | 439 ms | 14284 KiB |
| 01-07.txt | AC | 71 ms | 4796 KiB |
| 01-08.txt | AC | 453 ms | 14276 KiB |
| 01-09.txt | AC | 433 ms | 10248 KiB |
| 01-10.txt | AC | 431 ms | 10232 KiB |
| 01-11.txt | AC | 433 ms | 10384 KiB |
| 01-12.txt | AC | 434 ms | 10228 KiB |
| 01-13.txt | AC | 433 ms | 10240 KiB |
| 01-14.txt | AC | 431 ms | 10156 KiB |