Submission #1964134
Source Code Expand
#include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1e9; const int MOD = 1e9 + 7; // 4近傍、8近傍 int dx[] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; int main() { // 入力 int N; cin >> N; ll T[N], A[N]; for (int i = 0; i < N; i++) cin >> T[i]; for (int i = 0; i < N; i++) cin >> A[i]; ll ans = 0; if (T[N-1] == A[0] && T[0] <= A[0]) { ans = 1; for (int i = 1; i < N - 1; i++) { if (T[i-1] < T[i]) { if (A[i] < T[i]) { ans = 0; break; } } else if (A[i] > A[i+1]) { if (T[i] < A[i]) { ans = 0; break; } } else { ans *= min(T[i], A[i]); ans %= MOD; } } } // 解答 cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | university |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1089 Byte |
Status | AC |
Exec Time | 86 ms |
Memory | 1792 KB |
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 | 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 | 86 ms | 1792 KB |
1_009.txt | AC | 70 ms | 1792 KB |
1_010.txt | AC | 75 ms | 1792 KB |
1_011.txt | AC | 80 ms | 1792 KB |
1_012.txt | AC | 76 ms | 1792 KB |
1_013.txt | AC | 78 ms | 1792 KB |
1_014.txt | AC | 79 ms | 1792 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 | 71 ms | 1792 KB |
1_020.txt | AC | 59 ms | 1792 KB |