Submission #19352265


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;

ll n,m;
vector<ll>adj[N];
ll a[N];
bool visited[N];
ll high[N];
ll ans=ninf;

void dfs(ll x)
{
    visited[x]=true;

    high[x]=max(high[x],a[x]);

    for(auto it: adj[x])
    {
        if(!visited[it])
        dfs(it);

        high[x]=max(high[x],high[it]);
    }
}

int main()
{
    lscf(n),lscf(m);

    rep(i,1,n+1)
    lscf(a[i]);

    while(m--)
    {
        ll x,y;
        lscf(x),lscf(y);
        adj[x].pb(y);
    }
    rep(i,1,n+1)
    high[i]=ninf;

    rep(i,1,n+1)
    {
        if(!visited[i])
        dfs(i);
    }

    rep(i,1,n+1)
    {
        for(auto it: adj[i])
        {
            ans=max(ans,high[it]-a[i]);
        }
    }

    lpri(ans);
return 0;
}

Submission Info

Submission Time
Task E - Peddler
User TejaMeraNaam
Language C++ (GCC 9.2.1)
Score 500
Code Size 1664 Byte
Status AC
Exec Time 132 ms
Memory 49172 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:60:5: note: in expansion of macro ‘lscf’
   60 |     lscf(n),lscf(m);
      |     ^~~~
./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:60:13: note: in expansion of macro ‘lscf’
   60 |     lscf(n),lscf(m);
      |             ^~~~
./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:63:5: note: in expansion of macro ‘lscf’
   63 |     lscf(a[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:68:9: note: in expansion of macro ‘lscf’
   68 |         lscf(x),lscf(y);
      |         ^~~~
./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:68:17: note: in expansion of macro ‘lscf’
   68 |         lscf(x),lscf(y);
      |                 ^~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 49
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All extreme_00.txt, extreme_01.txt, extreme_02.txt, extreme_03.txt, handmade_00.txt, handmade_01.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, 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_dense_00.txt, random_dense_01.txt, random_dense_02.txt, random_dense_03.txt, random_dense_04.txt, random_dense_05.txt, random_dense_06.txt, random_dense_07.txt, random_dense_08.txt, random_dense_09.txt, random_small_00.txt, random_small_01.txt, random_small_02.txt, random_small_03.txt, random_small_04.txt, random_small_05.txt, random_small_06.txt, random_small_07.txt, random_small_08.txt, random_small_09.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
extreme_00.txt AC 132 ms 49172 KB
extreme_01.txt AC 82 ms 31692 KB
extreme_02.txt AC 84 ms 33928 KB
extreme_03.txt AC 50 ms 30496 KB
handmade_00.txt AC 24 ms 27116 KB
handmade_01.txt AC 25 ms 26916 KB
random_00.txt AC 80 ms 32104 KB
random_01.txt AC 88 ms 32328 KB
random_02.txt AC 57 ms 29484 KB
random_03.txt AC 48 ms 29516 KB
random_04.txt AC 50 ms 28948 KB
random_05.txt AC 50 ms 29692 KB
random_06.txt AC 36 ms 27680 KB
random_07.txt AC 64 ms 30836 KB
random_08.txt AC 78 ms 30688 KB
random_09.txt AC 62 ms 31372 KB
random_10.txt AC 49 ms 28768 KB
random_11.txt AC 89 ms 32600 KB
random_12.txt AC 54 ms 30040 KB
random_13.txt AC 85 ms 32620 KB
random_14.txt AC 60 ms 29896 KB
random_15.txt AC 94 ms 33048 KB
random_16.txt AC 63 ms 30180 KB
random_17.txt AC 97 ms 33296 KB
random_18.txt AC 26 ms 27676 KB
random_19.txt AC 67 ms 31636 KB
random_dense_00.txt AC 36 ms 28200 KB
random_dense_01.txt AC 51 ms 29260 KB
random_dense_02.txt AC 52 ms 29156 KB
random_dense_03.txt AC 49 ms 28592 KB
random_dense_04.txt AC 22 ms 27060 KB
random_dense_05.txt AC 31 ms 27756 KB
random_dense_06.txt AC 52 ms 29244 KB
random_dense_07.txt AC 22 ms 27172 KB
random_dense_08.txt AC 57 ms 29396 KB
random_dense_09.txt AC 35 ms 27632 KB
random_small_00.txt AC 21 ms 26996 KB
random_small_01.txt AC 20 ms 26920 KB
random_small_02.txt AC 30 ms 26916 KB
random_small_03.txt AC 26 ms 27044 KB
random_small_04.txt AC 21 ms 26928 KB
random_small_05.txt AC 22 ms 27116 KB
random_small_06.txt AC 21 ms 26924 KB
random_small_07.txt AC 20 ms 27076 KB
random_small_08.txt AC 23 ms 27120 KB
random_small_09.txt AC 24 ms 27116 KB
sample_01.txt AC 21 ms 27116 KB
sample_02.txt AC 27 ms 27012 KB
sample_03.txt AC 22 ms 27132 KB