Submission #19353996


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll ; 
# define int long long 
const int nax = 2e5 + 5 ; 

int n ;
ll c ;

int32_t  main()
{
	IOS ;
	cin >> n >> c ;
	map<ll,ll> ultimate_weapon ;

	for(int i = 0 ; i < n ; ++i) {
		ll l ,r , val ;
		cin >> l >> r >> val ;
		ultimate_weapon[l] += val ;
		ultimate_weapon[r + 1] -= val ; 
	}
	
	ll cur = 0 ;
	long long ans = 0 ;
	vector<pair<int,int>> hope ; 
	for(auto x : ultimate_weapon) {
		hope.push_back({x.first, cur + x.second}) ;
		cur += x.second ;
	}
	sort(hope.begin(), hope.end()) ;
	for(int i = 0 ; i + 1 < (int)hope.size() ; ++i) {
		long long interval = hope[i+1].first - hope[i].first ;
		ans += min(interval * hope[i].second , interval * c) ;
	}
	cout << ans ;

	return 0 ;
}

Submission Info

Submission Time
Task D - Snuke Prime
User wa_magnet
Language C++ (GCC 9.2.1)
Score 0
Code Size 857 Byte
Status WA
Exec Time 385 ms
Memory 36524 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 27
WA × 1
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, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 18 ms 3592 KB
random_02.txt AC 2 ms 3580 KB
random_03.txt AC 2 ms 3520 KB
random_04.txt AC 2 ms 3484 KB
random_05.txt AC 3 ms 3580 KB
random_06.txt AC 2 ms 3460 KB
random_07.txt AC 3 ms 3544 KB
random_08.txt AC 3 ms 3528 KB
random_09.txt AC 2 ms 3620 KB
random_10.txt AC 2 ms 3460 KB
random_11.txt AC 3 ms 3528 KB
random_12.txt AC 2 ms 3584 KB
random_13.txt AC 3 ms 3520 KB
random_14.txt AC 2 ms 3604 KB
random_15.txt AC 3 ms 3576 KB
random_16.txt AC 83 ms 12096 KB
random_17.txt AC 184 ms 21204 KB
random_18.txt AC 160 ms 19304 KB
random_19.txt AC 144 ms 18480 KB
random_20.txt AC 382 ms 36280 KB
random_21.txt AC 256 ms 29536 KB
random_22.txt AC 27 ms 6412 KB
random_23.txt AC 385 ms 36520 KB
random_24.txt AC 383 ms 36524 KB
random_25.txt WA 51 ms 3484 KB
sample_01.txt AC 2 ms 3484 KB
sample_02.txt AC 3 ms 3532 KB
sample_03.txt AC 2 ms 3584 KB