Submission #19347502


Source Code Expand

#include <bits/stdc++.h>
#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define CREP(i, l, r) for(int i = l; i <= r; i++)
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> T; 
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> V;
typedef vector<ll> Vll;
const int INF = 1000000010;      //10^9, 2*INF
const ll LLINF = (1LL << 60);   // > 10^18 ll  2*LLINF

int main() {
    int n,m;
    cin >> n >> m;
    V a(n);rep(i, n) scanf("%d", &a[i]);
    V b(n,INF);
    vector<V> g(n);
    rep(i,m){
        int x,y;
        scanf("%d%d", &x, &y);
        x--; y--;
        g[x].emplace_back(y);
    }

    rep(i,n){
        //b[i] = min(a[i],b[i]);
        int cv = i;
        rep(j,g[i].size()){
            int nv = g[i][j];
            b[nv] = min(b[nv],min(b[cv],a[cv]));            
        }
    }

    int res = -2*INF;
    rep(i,n){
        if(b[i] != INF && a[i] - b[i] > res) res = a[i] - b[i];
    }

    printf("%d",res);
}

Submission Info

Submission Time
Task E - Peddler
User samari06
Language C++ (GCC 9.2.1)
Score 500
Code Size 1014 Byte
Status AC
Exec Time 90 ms
Memory 15520 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   17 |     V a(n);rep(i, n) scanf("%d", &a[i]);
      |                      ~~~~~^~~~~~~~~~~~~
./Main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   22 |         scanf("%d%d", &x, &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 90 ms 15520 KiB
extreme_01.txt AC 64 ms 10492 KiB
extreme_02.txt AC 71 ms 13216 KiB
extreme_03.txt AC 40 ms 9628 KiB
handmade_00.txt AC 2 ms 3752 KiB
handmade_01.txt AC 1 ms 3620 KiB
random_00.txt AC 59 ms 10872 KiB
random_01.txt AC 77 ms 9820 KiB
random_02.txt AC 42 ms 4892 KiB
random_03.txt AC 35 ms 6808 KiB
random_04.txt AC 31 ms 4692 KiB
random_05.txt AC 27 ms 8144 KiB
random_06.txt AC 14 ms 4004 KiB
random_07.txt AC 49 ms 8740 KiB
random_08.txt AC 56 ms 6452 KiB
random_09.txt AC 45 ms 10408 KiB
random_10.txt AC 26 ms 5228 KiB
random_11.txt AC 73 ms 10836 KiB
random_12.txt AC 38 ms 8088 KiB
random_13.txt AC 64 ms 11576 KiB
random_14.txt AC 43 ms 7184 KiB
random_15.txt AC 72 ms 10972 KiB
random_16.txt AC 47 ms 7240 KiB
random_17.txt AC 76 ms 12156 KiB
random_18.txt AC 13 ms 4432 KiB
random_19.txt AC 50 ms 10672 KiB
random_dense_00.txt AC 27 ms 4424 KiB
random_dense_01.txt AC 36 ms 4780 KiB
random_dense_02.txt AC 36 ms 4732 KiB
random_dense_03.txt AC 34 ms 4592 KiB
random_dense_04.txt AC 2 ms 3632 KiB
random_dense_05.txt AC 15 ms 3960 KiB
random_dense_06.txt AC 33 ms 4708 KiB
random_dense_07.txt AC 6 ms 3792 KiB
random_dense_08.txt AC 40 ms 4692 KiB
random_dense_09.txt AC 16 ms 4040 KiB
random_small_00.txt AC 2 ms 3584 KiB
random_small_01.txt AC 2 ms 3556 KiB
random_small_02.txt AC 1 ms 3624 KiB
random_small_03.txt AC 3 ms 3584 KiB
random_small_04.txt AC 2 ms 3752 KiB
random_small_05.txt AC 3 ms 3740 KiB
random_small_06.txt AC 1 ms 3624 KiB
random_small_07.txt AC 2 ms 3708 KiB
random_small_08.txt AC 2 ms 3696 KiB
random_small_09.txt AC 2 ms 3624 KiB
sample_01.txt AC 5 ms 3736 KiB
sample_02.txt AC 3 ms 3708 KiB
sample_03.txt AC 2 ms 3624 KiB