Submission #19336189


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M;
ll A[202020];
vector<int> E[202020];
ll dp[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>A[i];
		dp[i]=1LL<<60;
	}
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
	}
	ll ret=-1LL<<60;
	FOR(i,N) {
		ret=max(ret,A[i]-dp[i]);
		dp[i]=min(A[i],dp[i]);
		FORR(e,E[i]) dp[e]=min(dp[e],dp[i]);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task E - Peddler
User kmjp
Language C++ (GCC 9.2.1)
Score 500
Code Size 1210 Byte
Status AC
Exec Time 87 ms
Memory 17608 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:32:15: warning: left shift of negative value [-Wshift-negative-value]
   32 |  ll ret=-1LL<<60;
      |               ^~
./Main.cpp:21:8: warning: unused variable ‘j’ [-Wunused-variable]
   21 |  int i,j,k,l,r,x,y; string s;
      |        ^
./Main.cpp:21:10: warning: unused variable ‘k’ [-Wunused-variable]
   21 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:21:12: warning: unused variable ‘l’ [-Wunused-variable]
   21 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:21:14: warning: unused variable ‘r’ [-Wunused-variable]
   21 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:45:38: note: in expansion of macro ‘FOR’
   45 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

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 87 ms 17608 KB
extreme_01.txt AC 58 ms 11948 KB
extreme_02.txt AC 62 ms 14796 KB
extreme_03.txt AC 34 ms 11364 KB
handmade_00.txt AC 9 ms 8236 KB
handmade_01.txt AC 11 ms 8328 KB
random_00.txt AC 54 ms 13056 KB
random_01.txt AC 63 ms 12828 KB
random_02.txt AC 39 ms 9740 KB
random_03.txt AC 33 ms 10644 KB
random_04.txt AC 28 ms 9360 KB
random_05.txt AC 24 ms 10912 KB
random_06.txt AC 16 ms 8708 KB
random_07.txt AC 47 ms 11984 KB
random_08.txt AC 52 ms 10792 KB
random_09.txt AC 45 ms 12320 KB
random_10.txt AC 33 ms 9872 KB
random_11.txt AC 61 ms 13396 KB
random_12.txt AC 39 ms 11148 KB
random_13.txt AC 58 ms 13620 KB
random_14.txt AC 42 ms 10904 KB
random_15.txt AC 67 ms 13792 KB
random_16.txt AC 36 ms 11068 KB
random_17.txt AC 68 ms 14148 KB
random_18.txt AC 17 ms 8936 KB
random_19.txt AC 43 ms 12608 KB
random_dense_00.txt AC 28 ms 8852 KB
random_dense_01.txt AC 31 ms 9180 KB
random_dense_02.txt AC 32 ms 9260 KB
random_dense_03.txt AC 32 ms 8984 KB
random_dense_04.txt AC 10 ms 8356 KB
random_dense_05.txt AC 15 ms 8684 KB
random_dense_06.txt AC 32 ms 9148 KB
random_dense_07.txt AC 11 ms 8432 KB
random_dense_08.txt AC 35 ms 9312 KB
random_dense_09.txt AC 16 ms 8520 KB
random_small_00.txt AC 13 ms 8336 KB
random_small_01.txt AC 7 ms 8304 KB
random_small_02.txt AC 4 ms 8344 KB
random_small_03.txt AC 8 ms 8340 KB
random_small_04.txt AC 8 ms 8176 KB
random_small_05.txt AC 7 ms 8300 KB
random_small_06.txt AC 7 ms 8280 KB
random_small_07.txt AC 7 ms 8372 KB
random_small_08.txt AC 6 ms 8284 KB
random_small_09.txt AC 7 ms 8292 KB
sample_01.txt AC 12 ms 8220 KB
sample_02.txt AC 11 ms 8232 KB
sample_03.txt AC 10 ms 8228 KB