Submission #19336052


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;



int main()
{
    ll n,c;
    lscf(n),lscf(c);

    ll start[n+1],end[n+1],cost[n+1];

    map<ll,ll>m;

    rep(i,1,n+1)
    {
        lscf(start[i]),lscf(end[i]),lscf(cost[i]);

        m[start[i]]+=cost[i];
        m[end[i]+1]-=cost[i];
    }

    ll sum=0,ans=0;

    pair<ll,ll>prev={-1,-1};

    for(auto it: m)
    {
        if(prev.F==-1)
        prev={it.F,it.S};
        else
        {
            sum+=prev.S;
            ll days=it.F-prev.F;
            if(c<sum)
            ans+=days*c;
            else 
            ans+=days*sum;
            prev={it.F,it.S};
           // sum+=it.S;
        }
    }

    lpri(ans);
return 0;
}

Submission Info

Submission Time
Task D - Snuke Prime
User TejaMeraNaam
Language C++ (GCC 9.2.1)
Score 400
Code Size 1616 Byte
Status AC
Exec Time 360 ms
Memory 33408 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    8 | #define lscf(n) scanf("%lld",&n)
      |                 ~~~~~^~~~~~~~~~~
./Main.cpp:41:5: note: in expansion of macro ‘lscf’
   41 |     lscf(n),lscf(c);
      |     ^~~~
./Main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    8 | #define lscf(n) scanf("%lld",&n)
      |                 ~~~~~^~~~~~~~~~~
./Main.cpp:41:13: note: in expansion of macro ‘lscf’
   41 |     lscf(n),lscf(c);
      |             ^~~~
./Main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    8 | #define lscf(n) scanf("%lld",&n)
      |                 ~~~~~^~~~~~~~~~~
./Main.cpp:49:9: note: in expansion of macro ‘lscf’
   49 |         lscf(start[i]),lscf(end[i]),lscf(cost[i]);
      |         ^~~~
./Main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    8 | #define lscf(n) scanf("%lld",&n)
      |                 ~~~~~^~~~~~~~~~~
./Main.cpp:49:24: note: in expansion of macro ‘lscf’
   49 |         lscf(start[i]),lscf(end[i]),lscf(cost[i]);
      |                        ^~~~
./Main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    8 | #define lscf(n) scanf("%lld",&n)
      |                 ~~~~~^~~~~~~~~~~
./Main.cpp:49:37: note: in expansion of macro ‘lscf’
   49 |         lscf(start[i]),lscf(end[i]),lscf(cost[i]);
      |                                     ^~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 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 AC 3 ms 3688 KB
random_02.txt AC 2 ms 3764 KB
random_03.txt AC 2 ms 3692 KB
random_04.txt AC 2 ms 3636 KB
random_05.txt AC 2 ms 3764 KB
random_06.txt AC 2 ms 3616 KB
random_07.txt AC 2 ms 3656 KB
random_08.txt AC 2 ms 3732 KB
random_09.txt AC 3 ms 3616 KB
random_10.txt AC 2 ms 3732 KB
random_11.txt AC 1 ms 3780 KB
random_12.txt AC 2 ms 3744 KB
random_13.txt AC 2 ms 3760 KB
random_14.txt AC 2 ms 3632 KB
random_15.txt AC 2 ms 3688 KB
random_16.txt AC 70 ms 11760 KB
random_17.txt AC 157 ms 20232 KB
random_18.txt AC 121 ms 18084 KB
random_19.txt AC 114 ms 16812 KB
random_20.txt AC 310 ms 33168 KB
random_21.txt AC 202 ms 25060 KB
random_22.txt AC 27 ms 6372 KB
random_23.txt AC 346 ms 33372 KB
random_24.txt AC 360 ms 33408 KB
random_25.txt AC 71 ms 8348 KB
sample_01.txt AC 2 ms 3652 KB
sample_02.txt AC 2 ms 3716 KB
sample_03.txt AC 2 ms 3732 KB