Submission #5310947
Source Code Expand
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<long long, long long> mp; for (int i = 0; i < n; ++i) { long long s, c; cin >> s >> c; auto itr = mp.lower_bound(s); long long fir = s, now = s; auto erfir = itr; if (itr != mp.begin()) { auto tmp = itr; --tmp; if (tmp->second > fir) { fir = tmp->first; now = tmp->second; erfir = tmp; } } while (itr != mp.end()) { long long dist = itr->first - now; if (dist < c) { c -= dist; now = itr->second; ++itr; } else break; } mp.erase(erfir, itr); now += c; cout << now - 1 << '\n'; mp[fir] = now; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Squares, Pieces and Coloring |
User | riantkb |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 906 Byte |
Status | AC |
Exec Time | 294 ms |
Memory | 7424 KB |
Judge Result
Set Name | Sample | Dataset1 | Dataset2 | Dataset3 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 35 / 35 | 40 / 40 | 25 / 25 | ||||||||
Status |
|
|
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt |
Dataset1 | sample-01.txt, sample-02.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 |
Dataset2 | sample-01.txt, sample-02.txt, sample-03.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt |
Dataset3 | sample-01.txt, sample-02.txt, 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, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 03-01.txt, 03-02.txt, 03-03.txt, 03-04.txt, 03-05.txt, 03-06.txt, 03-07.txt, 03-08.txt, 03-09.txt, 03-10.txt, 03-11.txt, 03-12.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 111 ms | 512 KB |
01-02.txt | AC | 208 ms | 768 KB |
01-03.txt | AC | 235 ms | 1792 KB |
01-04.txt | AC | 136 ms | 3712 KB |
01-05.txt | AC | 1 ms | 256 KB |
01-06.txt | AC | 1 ms | 256 KB |
01-07.txt | AC | 3 ms | 256 KB |
01-08.txt | AC | 24 ms | 384 KB |
01-09.txt | AC | 159 ms | 1792 KB |
02-01.txt | AC | 4 ms | 256 KB |
02-02.txt | AC | 4 ms | 256 KB |
02-03.txt | AC | 4 ms | 256 KB |
02-04.txt | AC | 3 ms | 256 KB |
02-05.txt | AC | 4 ms | 256 KB |
02-06.txt | AC | 4 ms | 256 KB |
02-07.txt | AC | 4 ms | 256 KB |
02-08.txt | AC | 4 ms | 256 KB |
02-09.txt | AC | 4 ms | 256 KB |
02-10.txt | AC | 1 ms | 256 KB |
02-11.txt | AC | 1 ms | 256 KB |
02-12.txt | AC | 4 ms | 256 KB |
03-01.txt | AC | 269 ms | 1664 KB |
03-02.txt | AC | 262 ms | 1664 KB |
03-03.txt | AC | 259 ms | 1664 KB |
03-04.txt | AC | 205 ms | 768 KB |
03-05.txt | AC | 283 ms | 7424 KB |
03-06.txt | AC | 260 ms | 1664 KB |
03-07.txt | AC | 256 ms | 1664 KB |
03-08.txt | AC | 294 ms | 7424 KB |
03-09.txt | AC | 293 ms | 7424 KB |
03-10.txt | AC | 27 ms | 384 KB |
03-11.txt | AC | 264 ms | 1664 KB |
03-12.txt | AC | 260 ms | 1664 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |
sample-03.txt | AC | 1 ms | 256 KB |