Submission #1164058
Source Code Expand
#include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cmath> typedef long long ll; #define fi first #define se second ll ans = 1; int N; ll T[112345]; ll A[112345]; int idx[112345]; using namespace std; int main(){ cin>>N; int i; int j; fill( idx, idx + 112345, 112345 ); for( i = 0; i < N; i++ ){ scanf("%lld", T+i); } for( i = 0; i < N; i++ ){ scanf("%lld", A+i); } //puts("1"); int before; before = 0; j = 0; for( i = 0; i < N; i++ ){ if( before < T[i] ){ if( T[i] > A[i] ) ans = 0; idx[j] = i; j++; } before = T[i]; } before = 0; for( i = N-1; i >= 0; i-- ){ if( before < A[i] ){ if( A[i] > T[i] ) ans = 0; idx[j] = i; j++; } before = A[i]; } //puts("2"); sort( idx, idx+j ); before = idx[0]; int cnt = 0; for( i = 1; i < j; i++ ){ if( idx[i] == before ){ idx[i] = 112345; cnt++; } before = idx[i]; } //puts("3"); sort( idx, idx+j ); j -= cnt; before = idx[0]; ll k; ll o; for( i = 1; i < j; i++ ){ k = idx[i] - before - 1; if( k ){ o = (ll)min( A[idx[i]-1], T[idx[i]-1] ); while( k-- ){ ans *= o; ans %= 1000000007; } // 123456789 } before = idx[i]; } printf("%lld", ans ); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | Ice_in_juice |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1521 Byte |
Status | AC |
Exec Time | 28 ms |
Memory | 2304 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:28:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", T+i); ^ ./Main.cpp:32:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", A+i); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 640 KB |
0_001.txt | AC | 1 ms | 640 KB |
0_002.txt | AC | 1 ms | 640 KB |
0_003.txt | AC | 1 ms | 640 KB |
1_004.txt | AC | 1 ms | 640 KB |
1_005.txt | AC | 1 ms | 640 KB |
1_006.txt | AC | 1 ms | 640 KB |
1_007.txt | AC | 1 ms | 640 KB |
1_008.txt | AC | 26 ms | 2304 KB |
1_009.txt | AC | 26 ms | 2304 KB |
1_010.txt | AC | 28 ms | 2304 KB |
1_011.txt | AC | 27 ms | 2304 KB |
1_012.txt | AC | 28 ms | 2304 KB |
1_013.txt | AC | 26 ms | 2304 KB |
1_014.txt | AC | 26 ms | 2304 KB |
1_015.txt | AC | 25 ms | 2304 KB |
1_016.txt | AC | 25 ms | 2304 KB |
1_017.txt | AC | 24 ms | 2304 KB |
1_018.txt | AC | 24 ms | 2304 KB |
1_019.txt | AC | 22 ms | 2304 KB |
1_020.txt | AC | 21 ms | 2304 KB |