Submission #19358889


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   fastIO
   int n,y; cin>>n>>y;
   map<int,int> mp;
   int ans=0;
   rep(i,0,n){
     int a,b,c; cin>>a>>b>>c;
     mp[a]+=c;
     mp[b+1]-=c;
     ans+=(b-a+1)*y;
   }
   int prev=-1;
   rr(mp){
      if(prev!=-1){
        if(y>mp[prev])ans-=(val.fi-prev)*y,ans+=(val.fi-prev)*mp[prev];
        val.se+=mp[prev];
      }
      prev=val.fi;
   }
   cout<<ans<<"\n";
   return 0;
}

Submission Info

Submission Time
Task D - Snuke Prime
User nagaraj41
Language C++ (GCC 9.2.1)
Score 0
Code Size 1503 Byte
Status WA
Exec Time 389 ms
Memory 28536 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
WA × 3
WA × 28
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 WA 6 ms 3444 KB
random_02.txt WA 2 ms 3544 KB
random_03.txt WA 3 ms 3544 KB
random_04.txt WA 3 ms 3460 KB
random_05.txt WA 3 ms 3592 KB
random_06.txt WA 2 ms 3620 KB
random_07.txt WA 2 ms 3588 KB
random_08.txt WA 5 ms 3448 KB
random_09.txt WA 2 ms 3580 KB
random_10.txt WA 2 ms 3544 KB
random_11.txt WA 2 ms 3548 KB
random_12.txt WA 2 ms 3544 KB
random_13.txt WA 2 ms 3452 KB
random_14.txt WA 2 ms 3544 KB
random_15.txt WA 3 ms 3504 KB
random_16.txt WA 81 ms 10440 KB
random_17.txt WA 181 ms 17352 KB
random_18.txt WA 163 ms 15568 KB
random_19.txt WA 144 ms 14664 KB
random_20.txt WA 389 ms 28336 KB
random_21.txt WA 263 ms 21564 KB
random_22.txt WA 27 ms 5816 KB
random_23.txt WA 375 ms 28536 KB
random_24.txt WA 362 ms 28508 KB
random_25.txt WA 55 ms 3572 KB
sample_01.txt WA 3 ms 3520 KB
sample_02.txt WA 3 ms 3564 KB
sample_03.txt WA 3 ms 3524 KB