Submission #2252145


Source Code Expand

#include<iostream>
#include<algorithm>
#include<set>
#define LL long long
LL N;
LL mod = 1000000000 + 7;
LL T[100010];
LL A[100010];
LL ans = 1;
int main() {
	std::cin >> N;
	LL bef = 0;
	for (int i = 1; i <= N; i++) {
		std::cin >> T[i];
	}
	for (int i = 1; i <= N; i++) {
		std::cin >> A[i];
	}
	if (T[1] > A[1] || T[N] < A[N]) {
		std::cout << 0 << std::endl;
		return 0;
	}
	for (int i = 2; i < N; i++) {
		if (T[i] == T[i - 1]) {
			if (A[i] == A[i + 1]) {
				ans *= std::min(T[i], A[i]);
			}
			else {
				if (T[i] < A[i]) {
					std::cout << 0 << std::endl;
					return 0;
				}
			}
		}
		else {
			if (A[i] < T[i]) {
				std::cout << 0 << std::endl;
				return 0;
			}
			if (A[i + 1] != A[i] &&  T[i] != A[i]) {
				std::cout << 0 << std::endl;
				return 0;
			}
		}
		ans %= mod;
	}
	std::cout << ans << std::endl;
	return 0;
}

Submission Info

Submission Time
Task C - Two Alpinists
User ikefumy
Language C++14 (GCC 5.4.1)
Score 400
Code Size 889 Byte
Status AC
Exec Time 87 ms
Memory 1920 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 21
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 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
0_003.txt AC 1 ms 256 KB
1_004.txt AC 1 ms 256 KB
1_005.txt AC 1 ms 256 KB
1_006.txt AC 1 ms 256 KB
1_007.txt AC 1 ms 256 KB
1_008.txt AC 87 ms 1792 KB
1_009.txt AC 71 ms 1792 KB
1_010.txt AC 76 ms 1792 KB
1_011.txt AC 80 ms 1792 KB
1_012.txt AC 76 ms 1792 KB
1_013.txt AC 80 ms 1792 KB
1_014.txt AC 78 ms 1920 KB
1_015.txt AC 80 ms 1792 KB
1_016.txt AC 77 ms 1792 KB
1_017.txt AC 74 ms 1792 KB
1_018.txt AC 72 ms 1792 KB
1_019.txt AC 63 ms 1792 KB
1_020.txt AC 59 ms 1792 KB