Submission #26319477


Source Code Expand

#include <bits/stdc++.h>
#define ll long long 
#define ft first
#define sec second
#define pb push_back
#define pf push_front
#define pr pair<ll,ll>
#define bged(a) a.begin(),a.end()
#define ISCC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#pragma optimize("Ofast","unroll-loop")
using namespace std;
const int MOD = 1e9+7; 
ll t ,n ,m ,d[400005] ,ans[200005] ,mx;
pr a[200005];
vector<ll> vec;
int num(int x){return lower_bound(bged(vec) ,x)-vec.begin()+1;}
int main()
{ 		
	cin >> n;
	for(int i=1 ,x, y ;i<=n ;i++)
	{
		cin >> x >> y;
		vec.pb(x) ,vec.pb(x+y);
		a[i].ft = x;  a[i].sec = x+y;
	} 	
	sort(bged(vec));
	vec.erase(unique(bged(vec)) ,vec.end());
	for(int i=1 ;i<=n ;i++)
	{
		d[num(a[i].ft)]++;  
		d[num(a[i].sec)]--;
	}
	int k = vec.size();
	for(int i=1 ;i<=k ;i++)
	{
		d[i] += d[i-1];		
		ans[d[i]] += vec[i]-vec[i-1];
	} 
	for(int i=1 ;i<=n ;i++) cout << ans[i] << ' ';
	return 0; 
}

Submission Info

Submission Time
Task D - Online games
User ck1080012
Language C++ (GCC 9.2.1)
Score 400
Code Size 948 Byte
Status AC
Exec Time 218 ms
Memory 14144 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 24
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 6 ms 3540 KiB
example_01.txt AC 3 ms 3560 KiB
hand_00.txt AC 144 ms 9768 KiB
hand_01.txt AC 6 ms 3412 KiB
hand_02.txt AC 182 ms 11200 KiB
hand_03.txt AC 215 ms 13984 KiB
hand_04.txt AC 7 ms 3564 KiB
hand_05.txt AC 2 ms 3540 KiB
hand_06.txt AC 132 ms 9772 KiB
hand_07.txt AC 90 ms 7504 KiB
hand_08.txt AC 183 ms 12748 KiB
hand_09.txt AC 218 ms 14144 KiB
random_00.txt AC 187 ms 10572 KiB
random_01.txt AC 189 ms 10628 KiB
random_02.txt AC 185 ms 10600 KiB
random_03.txt AC 181 ms 10608 KiB
random_04.txt AC 185 ms 10628 KiB
random_05.txt AC 176 ms 11724 KiB
random_06.txt AC 175 ms 11732 KiB
random_07.txt AC 175 ms 11508 KiB
random_08.txt AC 216 ms 13588 KiB
random_09.txt AC 218 ms 13548 KiB
random_10.txt AC 217 ms 13544 KiB
random_11.txt AC 217 ms 13524 KiB