Submission #1043293

# Submission time Handle Problem Language Result Execution time Memory
1043293 2024-08-04T07:51:39 Z vjudge1 Meteors (POI11_met) C++17
61 / 100
6000 ms 34088 KB
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣶⣶⣶⣶⠦⠶⡶⢦⠤⠤⠤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣠⣴⣶⣿⣿⣿⣿⣿⣿⣽⣽⣿⣿⣿⣿⣿⣭⣽⣭⣯⡭⡈⢙⣽⣶⣤⣤⣄⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣶⣟⣟⣽⣾⣿⢿⣿⡿⣿⣿⣿⣿⣿⣿⣟⠟⡻⣿⣿⣟⣟⣟⣿⡻⠿⠿⠿⠿⣍⠉⠉⠉⠙⠛⠛⠒⠒⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣶⣿⣿⣿⣿⡿⣾⣿⣯⣿⣿⣿⣽⣿⣷⣽⣿⣿⡿⣿⣿⣾⢿⣿⡷⣿⣿⣿⣿⣯⣭⡅⣠⣹⣢⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⡿⣿⣟⣽⣿⣿⣿⣻⣿⣟⣟⣿⣻⣿⣝⣿⣯⣿⣻⣻⣿⣿⣿⣿⡪⡻⣿⣿⣽⣿⣿⣯⣻⣿⣶⣿⣖⣓⡤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠿⢿⣿⣟⣿⣿⣻⣿⣿⣿⠿⣿⣿⡿⣿⣿⢿⣿⡯⣿⣛⣿⣕⣿⣿⡿⣿⣿⣷⢿⡿⣻⣿⣿⣿⢿⣿⣿⡻⣿⡷⠷⠯⠦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⡽⠹⠩⡝⡇⡿⢻⢻⢻⡛⣿⣹⣿⣿⣿⣿⣿⣽⣿⣯⣿⣿⣿⡿⣿⣿⣿⣿⣽⡿⣿⣯⣻⣿⣿⡿⣿⣿⣿⣿⣿⣝⡍⠩⠀⢘⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣏⣓⣂⣀⣀⠀⣜⣀⣀⠐⠐⠓⣞⠨⣿⠿⣗⣿⣿⣻⣿⣿⣽⣿⣿⣺⣿⣿⣿⣿⣻⣿⣿⣿⣝⢿⣛⠻⣻⣿⣟⣟⣿⣿⣿⣤⣐⣒⣚⣳⡀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⠟⠻⠽⢯⣌⣶⣿⠿⡡⢴⣾⠛⢀⣷⡉⡟⣷⢊⢘⢀⡙⣷⣾⣿⣿⣿⣿⣿⣿⢿⣿⢿⣿⡿⣿⣿⣽⢋⣝⣿⡿⣿⢿⢿⣛⢿⣿⣗⢇⠟⢦⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢾⣿⣿⣉⣉⣉⣸⣿⣿⣉⣉⢉⣿⠷⠶⠀⢸⣿⣿⢿⠀⠀⠀⠀⢸⠀⢀⡷⣿⣿⣿⢿⡿⡇⣿⣉⢾⣿⣿⠰⢶⡶⣿⣿⣿⣿⣹⣿⡀⠹⣿⣿⡹⣉⢷⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⡭⣥⣿⣾⣿⣿⣿⣿⣿⣿⣓⡃⠐⠀⣘⣯⣿⣚⣟⢒⣓⣒⣿⣒⢺⣟⣻⡧⡉⣿⡿⠍⡭⢭⠨⠹⢿⣝⢒⡞⠀⡖⣚⢷⣙⢛⣯⣦⠈⠻⢿⣿⣮⣧⡀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⢩⣿⣿⣿⣾⣷⣿⣿⣿⣟⠒⠀⠐⠀⠉⡿⡟⠉⠹⣿⣟⣳⣶⣆⣴⠑⠀⢳⡄⠈⣷⡁⠁⠈⠀⢈⠙⣷⠀⣀⣀⣀⠀⢨⣷⠀⠊⣟⢣⠀⠀⠉⠛⠿⣿⣄⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣗⡺⣿⣿⣿⣿⣿⣿⣿⡿⡏⠍⠁⢈⠀⠉⠁⣷⠩⠩⠨⢿⣷⣿⣿⡟⠀⠈⠅⠽⣹⣯⡵⣖⣶⣶⣶⡖⣿⡬⢭⡭⣽⣿⠭⣿⡠⠥⣼⣷⢧⠀⠀⠀⠀⠀⠙⠳⢄⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣿⡏⡃⢀⣠⣬⣶⣶⣦⣍⢀⠈⢸⣘⣧⣿⣿⣏⠀⣀⠀⣃⣷⢿⣼⣽⣆⡲⡦⢵⣾⣿⠃⣧⣿⣿⡼⣿⣿⣇⣻⣿⣘⡆⠀⠀⠀⠀⠀⠀⠈⠛
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢦⣾⠟⠻⠹⢰⣶⣆⡚⢷⡀⠠⠶⡞⣾⣿⠤⠀⠠⡀⢒⡞⠻⣷⠐⢻⣿⣮⡕⣷⣿⡖⣿⣿⣿⡏⣽⣿⣿⢶⣿⣿⢾⡄⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣽⣿⣿⡯⡿⢿⢽⣽⣮⣯⣯⡟⠬⠅⢡⡀⣠⣽⣿⣧⠵⠁⠀⠀⠇⡍⢿⠀⠀⠤⠀⠏⠩⠬⠹⡤⠀⣿⢝⡿⡯⣾⣯⣿⣟⣯⣖⣺⣿⣕⠽⣯⣿⣬⣽⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣻⣿⣿⠷⠿⠿⣻⣿⣟⣿⣿⠆⠁⢠⣿⣿⡽⠿⡿⣿⠀⠀⠀⠀⠀⠉⠋⠀⠀⠀⠀⠒⠉⠊⢈⠋⠁⡋⣻⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣷⣿⣿⣟⣹⣿⡆⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⡿⣿⣿⣿⣿⡭⢹⣿⣿⣻⣽⣿⡀⠀⢨⡇⠉⠍⢌⠼⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠴⣶⢶⠾⢦⣆⠂⠚⣿⣷⣽⡗⣿⡯⣿⠵⢿⣯⣯⣿⣿⣿⣕⣯⣇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣯⣿⣗⣿⣿⣿⡓⣒⣛⣽⣿⣿⢿⣯⠥⠀⠈⢶⡂⠐⣾⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠉⢙⣿⣌⣮⠽⣿⣍⢯⣻⣻⣯⠭⠥⣯⠬⣿⣿⣿⣟⣿⣻⣾⣏⢹⡀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⣾⣿⣷⣿⣿⡇⡇⠴⣹⣿⣿⣾⣉⢹⣄⡀⠀⠀⠉⠉⠀⠀⠀⠀⠀⠀⣠⡄⠀⠀⠀⠀⣀⣷⣶⣾⣿⣿⠈⠀⡉⣿⢙⣏⢾⣏⡉⡁⡁⣹⣿⣿⣳⣷⣿⣿⢞⣾⡌⡇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣯⣿⣿⣿⣿⣭⠭⢭⣿⣿⣷⡒⢀⡶⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡿⠇⠀⠀⠀⠰⡟⣿⢨⠽⢕⡟⠀⠂⣲⡟⠒⢺⣽⣷⣾⡶⠒⣺⣿⣯⣿⣿⣾⢽⣝⣿⠆⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⣿⣟⣿⣿⣿⣧⣚⣾⣚⣿⣿⠬⠤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠋⠀⠀⠀⠀⠐⣇⠈⢐⢰⡏⠁⠠⢠⡿⠤⣤⣿⣻⣟⣿⠥⣾⣿⣿⣿⣿⣿⣿⡾⡳⣿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡷⣿⣿⣿⣿⡿⣽⣿⢿⣿⣿⠶⠾⣿⣿⢉⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠒⠒⠛⠀⠤⠾⣛⣀⣽⣿⣿⣿⣿⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣯⣿⣿⣿⣿⣫⣫⣿⣿⢕⣿⣭⢹⡿⣿⣷⣐⣀⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⣢⣫⣿⣿⣟⣿⣿⣾⣻⣿⣿⣿⣿⣿⣿⣿⣿⣷⢿⡇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⢟⢟⣿⣿⣷⡿⣟⢄⣻⡻⣿⣷⡬⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣾⣛⣿⣿⡿⣿⣿⣟⢟⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⡄⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡿⣿⣿⣿⡗⣽⣿⣿⣿⣿⣕⡽⣍⢯⣿⣿⣿⢅⠠⠀⠀⠀⠀⠉⠙⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣬⣿⣿⣿⣿⣿⣿⣯⢿⣿⣿⡵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡽⣄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⢸⣿⣿⠇⢸⣿⣿⣯⣺⣿⣿⣿⣿⣿⣿⣦⢟⣿⣯⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣾⣿⣿⣿⣿⣿⣿⣗⣟⣿⣿⣺⡯⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣺⡆⠀⠀⠀⠀
⠀⠀⠀⠀⢀⣤⣶⣾⣷⣿⣿⣯⣳⡤⣀⣿⡏⠀⢸⣿⣿⣿⣾⠯⣿⣿⣿⣿⣿⣿⣿⢷⣿⣩⠨⠽⡿⣷⣄⠀⠀⠀⠀⠀⠀⠀⣀⣀⣠⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⣿⢏⣀⣻⣿⣿⣿⣿⣿⣿⣿⣾⡿⣿⣯⢿⡀⠀⠀⠀
⠀⢀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣟⣖⢤⣘⣿⣿⣿⣷⣽⣿⣿⣿⣿⣿⣿⣷⣗⣭⡿⣬⣭⡯⣭⣿⣿⣿⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣺⣿⣿⣿⣕⢒⣿⣿⣿⣿⣿⣿⣿⣿⣻⣾⡿⣿⣿⣇⠀⠀⠀
⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣝⢻⡻⣿⣟⣿⢟⡿⣿⣾⣿⣷⣟⢶⠐⢐⣰⣇⣲⣗⣾⢐⣐⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢽⣟⢽⣿⡺⢩⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⡯⡾⣿⢽⡄⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣾⡻⣷⣿⣟⢿⣿⣿⣿⣿⢷⡤⠀⠴⠑⠷⠶⠰⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣻⢿⣿⣿⣿⣿⣿⣿⣿⣻⣿⣯⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⢟⢟⢿⣿⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣝⣿⣿⣝⣿⣿⣿⣿⣷⣽⣄⠄⠀⠄⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢝⣿⡆⠙⠿⣿⣿⣿⣿⣺⣺⠟⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣗⣟⢽⠈⢿⡆⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⢾⣿⣿⣿⣿⣿⣾⣇⡀⠆⢀⣿⣿⣷⣿⣿⣿⣿⢿⣿⠁⠈⣿⣿⣿⢾⡇⠀⠀⠀⠹⣿⡿⣿⣉⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢏⣏⢾⠀⠀⣇⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣗⣿⣿⣿⣿⣿⣿⣮⡶⣤⣿⣿⣿⣿⣿⣿⣿⡿⣿⡗⠀⠀⠀⠙⢿⣿⣻⠀⠀⠀⠀⠈⣿⡿⣶⣾⣽⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⡏⠀⠀⣼⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢽⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣵⢝⢵⣿⡯⣯⠃⠀⠀⠀⠀⠀⠙⢿⡄⠀⠀⠀⢰⣿⠗⠉⠙⠿⣮⣧⡈⠻⣿⣿⣿⣿⣿⣿⣿⡯⣮⡇⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣫⣿⣿⣿⣿⣷⣿⣿⣿⣾⣾⣻⣻⣿⣻⣟⢿⣶⣄⡀⠀⠀⠀⠀⠀⠓⠀⠀⢠⡿⠁⠀⠀⠀⠀⠈⠙⠻⢦⠈⠿⣿⣿⣿⣿⣿⣟⣿⠁⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣾⣾⣿⣿⣿⣿⣾⣿⣿⣷⣽⣾⡿⣷⣤⣀⠀⠀⠀⠀⠀⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠓⠀⠈⠻⣿⣿⣿⣷⡏⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⡿⣿⣷⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣿⡟⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⡿⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣾⡿⣷⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⠃⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢯⣿⣯⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣯⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠋⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣿⠋⠀
*/
// skibidi rizz
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie()
#define ll long long
#define ull unsigned long long
#define pb push_back
// #define endl "\n"

// #define int ll
#define F first     
#define S second
#define db double 
#define ld long double
#define short unsigned short
#define pii pair<int,int>
using namespace std;
const   int inf = 2e9,MOD=1e9+7,N=3e5+10,MN=1e9+7,lim=1e6;
const long db Pie=acos(-1);
//...and justice for all
int binpow(int a,int p);  
struct skibskibidi{
  int l,r,ind,ans,need;
};
struct meteoritna{
  int l,r,a;
};
int t[N*4],mark[N*4];
void push(int l,int r,int x){
  t[x]+=(r-l+1)*mark[x];
  t[x]=min(t[x],inf);
  if(l==r){
    mark[x]=0;
    return ;
  }
  mark[x*2]+=mark[x];
  mark[x*2]=min(mark[x*2],inf);
  mark[x*2+1]+=mark[x];
  mark[x*2+1]=min(mark[x*2+1],inf);
  mark[x]=0;
}
void upd(int l,int r,int v,int x,int lx,int rx){
  push(lx,rx,x);
  if(l<=lx&&rx<=r){
    mark[x]+=v;
    push(lx,rx,x);
    return;
  }
  if(r<lx||rx<l){
    return ;
  }
  int m=(lx+rx)/2;
  upd(l,r,v,x*2,lx,m);
  upd(l,r,v,x*2+1,m+1,rx);
  t[x]=t[x*2]+t[x*2+1];
}
int get(int i,int x,int lx,int rx){
  push(lx,rx,x);
  if(lx==rx){
    return t[x];
  }
  int m=(lx+rx)/2;
  if(i<=m){
    return get(i,x*2,lx,m);
  }
  else{
    return get(i,x*2+1,m+1,rx);
  }
}
const void solve(){
  int n,m;
  cin>>n>>m;
  vector<skibskibidi>q(n+1);
  vector<vector<int>>gov(m+1);
  for(int i=1;i<=m;i++){
    int x;
    cin>>x;
    gov[x].pb(i);
  }
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    q[i]={0,0,i,-1,x};
  } 
  int k;
  cin>>k;
  for(int i=1;i<=n;i++){
    q[i].l=1;
    q[i].r=k;
  }
  vector<meteoritna>a(k+1);
  for(int i=1;i<=k;i++){
    cin>>a[i].l>>a[i].r>>a[i].a;
  }
  for(int gay=0;gay<30;gay++){
    vector<vector<int>>g(k+1);
    for(int i=1;i<=m*4;i++){
      t[i]=0;
      mark[i]=0;
    }
    for(int i=1;i<=n;i++){
      int mid=(q[i].l+q[i].r)/2;
      g[mid].pb(i);
      // cout<<mid<<" ";
    }
    for(int i=1;i<=k;i++){ 
      if(a[i].l<=a[i].r){
        upd(a[i].l,a[i].r,a[i].a,1,1,m);
      }
      else{
        upd(a[i].l,m,a[i].a,1,1,m);
        upd(1,a[i].r,a[i].a,1,1,m);
      }
      // for(int i=1;i<=m;i++){
      //   cout<<get(i,1,1,m)<<" ";
      // }
      // cout<<endl;
      for(auto to:g[i]){
        int sum=0;
        for(auto loc:gov[to]){
          sum+=get(loc,1,1,m);
          sum=min(sum,inf);
          // cout<<get(loc,1,1,m)<<" ";
        }
        int mid=(q[to].l+q[to].r)/2;
        if(sum>=q[to].need){
          q[to].ans=i;
          q[to].r=i-1;  
        }
        else{
          q[to].l=i+1;
        }
      }
    }
  }
  for(int i=1;i<=n;i++){
    if(q[i].ans==-1){
      cout<<"NIE"<<endl;
    }
    else  cout<<q[i].ans<<endl;
  }
}           
main() {
    srand(time(NULL));
    IOS;
    //freopen("c  oins.in", "r", stdin);
    //freopen("coins.out", "w", stdout);
    int UwU=1;
    // cin>>UwU;    
    for(int i=1;i<=UwU;i++) { 
      // cout<<"Case "<<i<<": ";
        solve(); 
      // cout<<endl;
    }
    cout<<fixed<<setprecision(10);
    cerr<<"Time:"<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n"; 
}
// int binmul(int a,int b){}
int binpow(int a,int p){if(p==0)return 1;if(p%2){return ((binpow(a,p-1)*a)%MOD);}int res=binpow(a,p/2)%MOD; return (res*res)%MOD;}

Compilation message

met.cpp: In function 'const void solve()':
met.cpp:170:13: warning: unused variable 'mid' [-Wunused-variable]
  170 |         int mid=(q[to].l+q[to].r)/2;
      |             ^~~
met.cpp: At global scope:
met.cpp:188:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  188 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2396 KB Output is correct
2 Correct 10 ms 348 KB Output is correct
3 Correct 10 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 348 KB Output is correct
2 Correct 11 ms 348 KB Output is correct
3 Correct 12 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 725 ms 5312 KB Output is correct
2 Correct 829 ms 7576 KB Output is correct
3 Correct 796 ms 7356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 778 ms 5820 KB Output is correct
2 Correct 863 ms 5676 KB Output is correct
3 Correct 843 ms 6368 KB Output is correct
4 Correct 206 ms 4428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 434 ms 5580 KB Output is correct
2 Correct 732 ms 6488 KB Output is correct
3 Correct 362 ms 2248 KB Output is correct
4 Correct 783 ms 6264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 771 ms 5208 KB Output is correct
2 Incorrect 738 ms 5804 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6046 ms 34088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6022 ms 33328 KB Time limit exceeded
2 Halted 0 ms 0 KB -