Submission #45640798


Source Code Expand

#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll n,m,ans[N];
typedef pair<ll,ll>PLL;
#define x first
#define y second
priority_queue<PLL,vector<PLL>,greater<PLL>>q;
priority_queue<int,vector<int>,greater<int>>id;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)id.push(i);
	for(int i=1,t,w,s;i<=m;i++)
	{
		cin>>t>>w>>s;
		while(q.size()&&q.top().x<=t)id.push(q.top().y),q.pop();
		if(id.size())
		{
			int now=id.top();
			id.pop();
			ans[now]+=w;
			q.push({t+s,now});
		}
	}
	for(int i=1;i<=n;i++)cout<<ans[i]<<'\n';
	return 0;
}

Submission Info

Submission Time
Task E - Somen Nagashi
User week_end
Language C++ 20 (gcc 12.2)
Score 475
Code Size 761 Byte
Status AC
Exec Time 68 ms
Memory 9120 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 41
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 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, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 59 ms 3584 KiB
random_02.txt AC 68 ms 4240 KiB
random_03.txt AC 36 ms 3624 KiB
random_04.txt AC 59 ms 3604 KiB
random_05.txt AC 39 ms 3492 KiB
random_06.txt AC 39 ms 4352 KiB
random_07.txt AC 33 ms 3628 KiB
random_08.txt AC 52 ms 4084 KiB
random_09.txt AC 59 ms 3572 KiB
random_10.txt AC 68 ms 4324 KiB
random_11.txt AC 59 ms 3656 KiB
random_12.txt AC 65 ms 3980 KiB
random_13.txt AC 31 ms 3628 KiB
random_14.txt AC 20 ms 4312 KiB
random_15.txt AC 39 ms 3624 KiB
random_16.txt AC 9 ms 3784 KiB
random_17.txt AC 36 ms 3648 KiB
random_18.txt AC 27 ms 3512 KiB
random_19.txt AC 22 ms 3648 KiB
random_20.txt AC 6 ms 3560 KiB
random_21.txt AC 54 ms 3588 KiB
random_22.txt AC 53 ms 3688 KiB
random_23.txt AC 52 ms 3532 KiB
random_24.txt AC 23 ms 3424 KiB
random_25.txt AC 36 ms 3668 KiB
random_26.txt AC 32 ms 3584 KiB
random_27.txt AC 35 ms 3664 KiB
random_28.txt AC 12 ms 3700 KiB
random_29.txt AC 54 ms 3740 KiB
random_30.txt AC 52 ms 3680 KiB
random_31.txt AC 25 ms 3608 KiB
random_32.txt AC 1 ms 3468 KiB
random_33.txt AC 54 ms 9120 KiB
random_34.txt AC 27 ms 3456 KiB
random_35.txt AC 31 ms 3396 KiB
random_36.txt AC 36 ms 6012 KiB
random_37.txt AC 38 ms 6104 KiB
random_38.txt AC 43 ms 6080 KiB
sample_01.txt AC 1 ms 3412 KiB
sample_02.txt AC 1 ms 3524 KiB
sample_03.txt AC 1 ms 3416 KiB