Submission #2251914


Source Code Expand

#include<iostream>
#include<algorithm>
#include<set>
#define LL long long
LL N;
LL mod = 1000000000 + 7;
LL R[100010];
LL A[100010];
LL ans = 1;
bool D[100010];
int main() {
	std::cin >> N;
	LL bef = 0;
	for (int i = 1; i <= N; i++) {
		LL tmp;
		std::cin >> tmp;
		if (tmp != bef) {
			D[i] = true;
		}
		R[i] = tmp;
		bef = tmp;
	}
	bef = 0;
	for (int i = 1; i <= N; i++) {
		LL tmp;
		std::cin >> tmp;
		if (i == N&&R[i]<tmp) {
			std::cout << 0 << std::endl;
			return 0;
		}
		if (bef != tmp) {
			if (R[i - 1] < bef) {
				std::cout << 0 << std::endl;
				return 0;
			}
			if (D[i - 1]) {
				if (R[i - 1] != bef) {
					std::cout << 0 << std::endl;
					return 0;
				}
			}
			D[i - 1] = true;
		}
		bef = tmp;
		A[i] = std::min(R[i], tmp);
	}
	D[N] = true;
	for (int i = 1; i <= N; i++) {
		if (!D[i]) {
			ans *= R[i];
			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 0
Code Size 951 Byte
Status WA
Exec Time 86 ms
Memory 1920 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
WA × 1
AC × 14
WA × 7
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 WA 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
0_003.txt AC 2 ms 384 KB
1_004.txt WA 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 86 ms 1792 KB
1_009.txt AC 70 ms 1920 KB
1_010.txt AC 75 ms 1920 KB
1_011.txt WA 80 ms 1920 KB
1_012.txt AC 46 ms 1152 KB
1_013.txt WA 79 ms 1920 KB
1_014.txt AC 45 ms 1152 KB
1_015.txt WA 80 ms 1792 KB
1_016.txt AC 49 ms 1280 KB
1_017.txt WA 74 ms 1792 KB
1_018.txt AC 55 ms 1408 KB
1_019.txt WA 63 ms 1792 KB
1_020.txt AC 49 ms 1280 KB