Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"You are given a rooted tree. Each vertex contains a_i tons of gold, which costs c_i per one ton. Initially, the tree consists only a root numbered 0 with a_0 tons of gold and price c_0 per ton. There are q queries. Each query has one of two types: If we buy x tons of gold in some vertex v the remaining amount of gold in it decreases by x (of course, we can't buy more gold that vertex has at the moment). For each query of the second type, calculate the resulting amount of gold we bought and the amount of money we should spend. Note that you should solve the problem in online mode. It means that you can't read the whole input at once. You can read each query only after writing the answer for the last query, so don't forget to flush output after printing answers. You can use functions like fflush(stdout) in C++ and BufferedWriter.flush in Java or similar after each writing in your program. In standard (if you don't tweak I/O), endl flushes cout in C++ and System.out.println in Java (or println in Kotlin) makes automatic flush as well. The first line contains three integers q , a_0 and c_0 ( 1 <= q <= 3 cdot 10^5 ; 1 <= a_0, c_0 < 10^6 ) -- the number of queries, the amount of gold in the root and its price. Next q lines contain descriptions of queries; The i -th query has one of two types: It's guaranteed that there is at least one query of the second type. For each query of the second type, print the resulting amount of gold we bought and the minimum amount of money we should spend. Explanation of the sample: At the first query, the tree consist of root, so we purchase 2 tons of gold and pay 2 cdot 2 = 4 . 3 tons remain in the root. At the second query, we add vertex 2 as a son of vertex 0 . Vertex 2 now has 3 tons of gold with price 4 per one ton. At the third query, a path from 2 to 0 consists of onl"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
118439962 |
Gassa |
E |
June 4, 2021, 4:37 p.m. |
OK |
D |
TESTS |
25 |
2058 |
37990400 |
|
|
118451549 |
rlblaster |
E |
June 4, 2021, 6:40 p.m. |
OK |
GNU C11 |
TESTS |
25 |
1637 |
27648000 |
|
|
118473818 |
cutx64 |
E |
June 5, 2021, 5:42 a.m. |
OK |
GNU C11 |
TESTS |
25 |
1715 |
27648000 |
|
|
118465654 |
Crab_Dave |
E |
June 5, 2021, 2:48 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
857 |
52940800 |
|
|
118438919 |
Rescuring |
E |
June 4, 2021, 4:33 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
888 |
26419200 |
|
|
118437248 |
huan_yp |
E |
June 4, 2021, 4:29 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
904 |
103424000 |
|
|
118443093 |
myx12345 |
E |
June 4, 2021, 4:57 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
920 |
33382400 |
|
|
118445945 |
huangxiaohua |
E |
June 4, 2021, 5:25 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
935 |
36147200 |
|
|
118462985 |
et3_tsy2.0 |
E |
June 5, 2021, 1:18 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
951 |
27648000 |
|
|
118465865 |
Pointy |
E |
June 5, 2021, 2:54 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
951 |
32768000 |
|
|
118450326 |
OrzJiian |
E |
June 4, 2021, 6:22 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
951 |
38502400 |
|
|
118441297 |
--HY-- |
E |
June 4, 2021, 4:44 p.m. |
OK |
GNU C++11 |
TESTS |
25 |
966 |
28876800 |
|
|
118464180 |
KJGKMTZB |
E |
June 5, 2021, 2:10 a.m. |
OK |
GNU C++11 |
TESTS |
25 |
982 |
25292800 |
|
|
118440421 |
ArminAzimi |
E |
June 4, 2021, 4:39 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1543 |
39731200 |
|
|
118449484 |
coder_pulkit_c |
E |
June 4, 2021, 6:09 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1543 |
55296000 |
|
|
118452491 |
tanishbothrayellow |
E |
June 4, 2021, 6:56 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1544 |
64921600 |
|
|
118454567 |
aaditya07 |
E |
June 4, 2021, 7:36 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1559 |
25292800 |
|
|
118452956 |
Sanatruk_Avtandilyan |
E |
June 4, 2021, 7:04 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1559 |
28876800 |
|
|
118453750 |
Abhishekverma7887 |
E |
June 4, 2021, 7:19 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1559 |
32768000 |
|
|
118459316 |
matterhunt |
E |
June 4, 2021, 9:47 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1559 |
65638400 |
|
|
118440474 |
anon_123coder |
E |
June 4, 2021, 4:39 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1574 |
52019200 |
|
|
118435510 |
talant110726 |
E |
June 4, 2021, 4:24 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1590 |
35942400 |
|
|
118449831 |
222IQ |
E |
June 4, 2021, 6:15 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
1591 |
89804800 |
|
|
118464061 |
mohamedeltair |
E |
June 5, 2021, 2:05 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
1387 |
33689600 |
|
|
118447452 |
Kallaseldor |
E |
June 4, 2021, 5:42 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
1434 |
32563200 |
|
|
118453040 |
bipinpathak |
E |
June 4, 2021, 7:05 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
1434 |
35123200 |
|
|
118435423 |
feng01xiu |
E |
June 4, 2021, 4:24 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
1435 |
8089600 |
|
|
118435854 |
PineapplesOnPizza |
E |
June 4, 2021, 4:25 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
1450 |
28876800 |
|
|
118474061 |
woshiluo |
E |
June 5, 2021, 5:46 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
1450 |
105574400 |
|
|
118454353 |
silvertint |
E |
June 4, 2021, 7:31 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
1465 |
32768000 |
|
|
118442135 |
amul_agrawal |
E |
June 4, 2021, 4:50 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
1481 |
28876800 |
|
|
118441181 |
xulantu |
E |
June 4, 2021, 4:44 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
1481 |
30105600 |
|
|
118468279 |
bpdolson |
E |
June 5, 2021, 3:58 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
1497 |
26419200 |
|
|
118449096 |
Commando_ |
E |
June 4, 2021, 6:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1200 |
26419200 |
|
|
118473471 |
PhaiCoGiaiQuocGia |
E |
June 5, 2021, 5:37 a.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1247 |
28160000 |
|
|
118443997 |
huangxiaohua |
E |
June 4, 2021, 5:05 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1294 |
36147200 |
|
|
118435892 |
ATSTNG |
E |
June 4, 2021, 4:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1341 |
28876800 |
|
|
118448975 |
Commando_ |
E |
June 4, 2021, 6:02 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1356 |
26419200 |
|
|
118463176 |
XOXOX |
E |
June 5, 2021, 1:28 a.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1356 |
50688000 |
|
|
118470547 |
Ripiaun |
E |
June 5, 2021, 4:47 a.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1372 |
24064000 |
|
|
118467040 |
delta_X |
E |
June 5, 2021, 3:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1372 |
176332800 |
|
|
118437334 |
Prateek |
E |
June 4, 2021, 4:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1387 |
57753600 |
|
|
118441938 |
akshaygahlot73 |
E |
June 4, 2021, 4:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
1387 |
64921600 |
|
|
118441529 |
0x3F |
E |
June 4, 2021, 4:46 p.m. |
OK |
Go |
TESTS |
25 |
2308 |
49561600 |
|
|
118475029 |
dusty.and.rusty |
E |
June 5, 2021, 6:01 a.m. |
OK |
Java 11 |
TESTS |
25 |
2183 |
34713600 |
|
|
118464763 |
uwi |
E |
June 5, 2021, 2:28 a.m. |
OK |
Java 11 |
TESTS |
25 |
3930 |
33484800 |
|
|
118464850 |
uwi |
E |
June 5, 2021, 2:30 a.m. |
OK |
Java 11 |
TESTS |
25 |
4055 |
42700800 |
|
|
118464508 |
uwi |
E |
June 5, 2021, 2:21 a.m. |
OK |
Java 11 |
TESTS |
25 |
4149 |
33587200 |
|
|
118456378 |
ritesharma |
E |
June 4, 2021, 8:10 p.m. |
OK |
Java 11 |
TESTS |
25 |
4492 |
42700800 |
|
|
118457408 |
augurar |
E |
June 4, 2021, 8:41 p.m. |
OK |
Java 8 |
TESTS |
25 |
1980 |
33075200 |
|
|
118433858 |
r57shell |
E |
June 4, 2021, 4:19 p.m. |
OK |
MS C++ |
TESTS |
25 |
1341 |
25292800 |
|
|
118433009 |
r57shell |
E |
June 4, 2021, 4:17 p.m. |
OK |
MS C++ |
TESTS |
25 |
1403 |
25292800 |
|
|
118443312 |
pichulia |
E |
June 4, 2021, 4:59 p.m. |
OK |
MS C++ 2017 |
TESTS |
25 |
1700 |
41676800 |
|
|
118442495 |
pichulia |
E |
June 4, 2021, 4:53 p.m. |
OK |
MS C++ 2017 |
TESTS |
25 |
1809 |
41676800 |
|
|
118449214 |
suVrik |
E |
June 4, 2021, 6:05 p.m. |
OK |
MS C++ 2017 |
TESTS |
25 |
2744 |
53145600 |
|
|
118445761 |
fairy_lettuce |
E |
June 4, 2021, 5:23 p.m. |
OK |
.NET Core C# |
TESTS |
25 |
2573 |
72294400 |
|
|
118443802 |
terry_u16 |
E |
June 4, 2021, 5:03 p.m. |
OK |
.NET Core C# |
TESTS |
25 |
2885 |
69120000 |
|
|
118437015 |
terry_u16 |
E |
June 4, 2021, 4:28 p.m. |
OK |
.NET Core C# |
TESTS |
25 |
3915 |
69222400 |
|
|
118470981 |
at_f |
E |
June 5, 2021, 4:55 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
3244 |
46592000 |
|
|
118470966 |
at_f |
E |
June 5, 2021, 4:55 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
3415 |
47923200 |
|
|
118474914 |
sh1194 |
E |
June 5, 2021, 5:59 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
3431 |
47923200 |
|
|
118474719 |
sh1194 |
E |
June 5, 2021, 5:57 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
3478 |
47820800 |
|
|
118474865 |
sh1194 |
E |
June 5, 2021, 5:59 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
3603 |
47820800 |
|
|
118465045 |
toomer |
E |
June 5, 2021, 2:35 a.m. |
OK |
Rust |
TESTS |
25 |
2666 |
32768000 |
|
|
118436991 |
cottoncotton |
E |
June 4, 2021, 4:28 p.m. |
OK |
Rust |
TESTS |
25 |
2776 |
34816000 |
|
|
118453270 |
sansen |
E |
June 4, 2021, 7:10 p.m. |
OK |
Rust |
TESTS |
25 |
2932 |
35840000 |
|
|
118442372 |
toomer |
E |
June 4, 2021, 4:52 p.m. |
OK |
Rust |
TESTS |
25 |
2932 |
50585600 |
|
|
remove filters
Back to search problems