Please sign in first.
Submission #3610687
Source Code Expand
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<pair<int, int>> plans;
for (int i = 0; i < n; ++i) {
int a, b;
cin >> a >> b;
plans.emplace_back(a, b);
}
sort(plans.begin(), plans.end());
int m;
cin >> m;
for (int i = 0; i < m; ++i) {
int t;
cin >> t;
int p1 = lower_bound(plans.begin(), plans.end(), make_pair(t, -1)) -
plans.begin();
int res = 2e9 + 7;
if (p1 < plans.size()) {
res = min(res, plans[p1].second);
}
if (p1 > 0) {
res = min(res, plans[p1 - 1].second + (t - plans[p1 - 1].first));
}
cout << res << '\n';
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Telephone Charge |
| User | dnk |
| Language | C++14 (GCC 5.4.1) |
| Score | 300 |
| Code Size | 763 Byte |
| Status | AC |
| Exec Time | 208 ms |
| Memory | 2164 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, sample_01.txt, sample_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 202 ms | 2164 KiB |
| 02.txt | AC | 208 ms | 2164 KiB |
| 03.txt | AC | 189 ms | 1784 KiB |
| 04.txt | AC | 108 ms | 1524 KiB |
| 05.txt | AC | 200 ms | 2164 KiB |
| 06.txt | AC | 195 ms | 1908 KiB |
| 07.txt | AC | 202 ms | 2164 KiB |
| 08.txt | AC | 77 ms | 768 KiB |
| sample_01.txt | AC | 1 ms | 256 KiB |
| sample_02.txt | AC | 1 ms | 256 KiB |