Submission #18132219
Source Code Expand
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define MAXN 100001
#define F first
#define S second
#define debug(x) cout<<x<<endl
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define pb push_back
#define mp make_pair
#define pi acos(-1)
// __int128->GNU G++ 17 9.2.0 Codeforces (but doesnot use with cout cin and cant take direct input use normal datatype the typecast )
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll = pair<ll,ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*STUDY*/
//https://codeforces.com/blog/entry/20935
//https://www.hackerrank.com/contests/mit-open-20-finals/challenges/fractions-arent-tough-or-are-they
//
// typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> is;
ll power(ll x,ll y){
if(y==0)
return 1;
ll res=power(x,y/2);
res=(res*res);
if(y&1)
res=(res*x);
return res;
}
ll powermod(ll x,ll y,ll mod){
if(y==0)
return 1;
ll res=powermod(x,y/2,mod);
res=(res*res)%mod;
if(y&1)
res=(res*x)%mod;
return res;
}
bool isPrime(ll n){
//There is a fact that the distance between adjacent prime numbers isn't big. For n = 10^9 maximal distanse is 282.
//https://stackoverflow.com/questions/31216097/given-n-and-k-return-the-kth-permutation-sequence
if(n<2)
return false;
for(ll i=3;i*i<=n;i+=2)
if(n%i==0)return false;
return true;
}
void factors(int n,vector<int> &fact){
vector<int> fact1;
for(int i=1;i*i<=n;i++)
{
if(n%i==0){
fact.pb(i);
if(n/i!=i)
fact1.pb(n/i);
}
}
for(int i=fact1.size()-1;i>=0;i--)
fact.pb(fact1[i]);
}
// stores smallest prime factor for every number
int spf[MAXN];
// Calculating SPF (Smallest Prime Factor) for every
// number till MAXN.
// Time Complexity : O(nloglogn)
void sieve()
{
spf[1] = 1;
for (int i=2; i<MAXN; i++)
// marking smallest prime factor for every
// number to be itself.
spf[i] = i;
// separately marking spf for every even
// number as 2
for (int i=4; i<MAXN; i+=2)
spf[i] = 2;
for (int i=3; i*i<MAXN; i++)
{
// checking if i is prime
if (spf[i] == i)
{
// marking SPF for all numbers divisible by i
for (int j=i*i; j<MAXN; j+=i)
// marking spf[j] if it is not
// previously marked
if (spf[j]==j)
spf[j] = i;
}
}
}
// A O(log n) function returning primefactorization
// by dividing by smallest prime factor at every step
vector<int> getFactorization(int x)
{
vector<int> ret;
while (x != 1)
{
ret.push_back(spf[x]);
x = x / spf[x];
}
return ret;
}
/*nCr*/
ll nCr(int n,int r){
if(n<r)return 0;
ll ans=1;
for(int i=1,j=n-r+1;i<=r;i++,j++) ans=ans*j/i;
return ans;
}
void solve(){
int n,s,t;ll w,p;
cin>>n>>w;
ll am[(int)(2e5)+20]={0};
for(int i=0;i<n;i++){
cin>>s>>t>>p;
am[s]+=p;
am[t]-=p;
}
for(int i=1;i<(int)(2e5)+20;i++)
{
am[i]+=am[i-1];
}
for(int i=0;i<(int)(2e5)+20;i++)
{
if(am[i]>w){
cout<<"No"<<endl;
return;
}
}
cout<<"Yes"<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//sieve();
int test=1;
//cin>>test;
for(int i=1;i<=test;i++)
{//cout<<"Case #"<<i<<": ";
solve();}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Water Heater |
| User | rounak_0501 |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 3930 Byte |
| Status | AC |
| Exec Time | 54 ms |
| Memory | 5228 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.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, sample_01.txt, sample_02.txt, sample_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| hand_01.txt | AC | 52 ms | 5140 KiB |
| hand_02.txt | AC | 45 ms | 5080 KiB |
| hand_03.txt | AC | 47 ms | 5124 KiB |
| hand_04.txt | AC | 45 ms | 5192 KiB |
| hand_05.txt | AC | 5 ms | 5120 KiB |
| random_01.txt | AC | 52 ms | 5148 KiB |
| random_02.txt | AC | 54 ms | 5084 KiB |
| random_03.txt | AC | 53 ms | 5160 KiB |
| random_04.txt | AC | 51 ms | 5080 KiB |
| random_05.txt | AC | 53 ms | 5076 KiB |
| random_06.txt | AC | 54 ms | 5148 KiB |
| random_07.txt | AC | 51 ms | 5092 KiB |
| random_08.txt | AC | 53 ms | 5228 KiB |
| random_09.txt | AC | 54 ms | 5072 KiB |
| random_10.txt | AC | 52 ms | 5176 KiB |
| sample_01.txt | AC | 5 ms | 5152 KiB |
| sample_02.txt | AC | 8 ms | 5172 KiB |
| sample_03.txt | AC | 4 ms | 5064 KiB |