Please sign in first.
Submission #26393374
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<pair<int, int>> q;
int n, k; cin >> n;
vector<int> day(n + 1);
int a, b;
for(int i = 0; i < n; i++)
{
cin >> a >> b;
q.push_back({a,1});
q.push_back({a + b,-1});
}
sort(q.begin(), q.end());
int cur = 0;
// {1,2}
// {2,3};
for(int i = 0; i < 2 * n; i++)
{
if(i > 0) {
day[cur] += (q[i].first - q[i - 1].first);
}
cur += q[i].second;
}
for(int i = 1; i <= n; i++)
{
cout << day[i] << " ";
}
cout << "\n";
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Online games |
| User | Tdpencil |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 655 Byte |
| Status | AC |
| Exec Time | 161 ms |
| Memory | 8152 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:7:12: warning: unused variable ‘k’ [-Wunused-variable]
7 | int n, k; cin >> n;
| ^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 10 ms | 3492 KiB |
| example_01.txt | AC | 2 ms | 3532 KiB |
| hand_00.txt | AC | 144 ms | 8028 KiB |
| hand_01.txt | AC | 7 ms | 3384 KiB |
| hand_02.txt | AC | 140 ms | 8028 KiB |
| hand_03.txt | AC | 161 ms | 7996 KiB |
| hand_04.txt | AC | 10 ms | 3388 KiB |
| hand_05.txt | AC | 2 ms | 3448 KiB |
| hand_06.txt | AC | 137 ms | 8148 KiB |
| hand_07.txt | AC | 89 ms | 5660 KiB |
| hand_08.txt | AC | 134 ms | 7932 KiB |
| hand_09.txt | AC | 158 ms | 8032 KiB |
| random_00.txt | AC | 157 ms | 7972 KiB |
| random_01.txt | AC | 158 ms | 7988 KiB |
| random_02.txt | AC | 158 ms | 8084 KiB |
| random_03.txt | AC | 157 ms | 7972 KiB |
| random_04.txt | AC | 155 ms | 7988 KiB |
| random_05.txt | AC | 131 ms | 8144 KiB |
| random_06.txt | AC | 129 ms | 8032 KiB |
| random_07.txt | AC | 129 ms | 8140 KiB |
| random_08.txt | AC | 158 ms | 8152 KiB |
| random_09.txt | AC | 160 ms | 8140 KiB |
| random_10.txt | AC | 157 ms | 8088 KiB |
| random_11.txt | AC | 158 ms | 8152 KiB |