Submission #1919313
Source Code Expand
// header {{{ #include <bits/stdc++.h> using namespace std; // {U}{INT,LONG,LLONG}_{MAX,MIN} #define INF INT_MAX/3 #define MOD (1000000007LL) using LL = long long; // }}} int main() { std::ios::sync_with_stdio(false); int n;cin >> n; vector<LL> t(n), a(n), th(n), ah(n); for(int i=0;i<n;i++) cin >> t[i]; for(int i=0;i<n;i++) cin >> a[i]; LL ans = 1; for(int i=0;i<n;i++){ th[i] = t[i]; if(i > 0){ if(t[i-1] == t[i]) th[i] = 0; } ah[i] = a[i]; if(i < n-1){ if(a[i] == a[i+1]) ah[i] = 0; } //cout << th[i] << " " << ah[i] << endl; if(th[i] == 0 && ah[i] == 0){ ans *= min(t[i], a[i]); ans %= MOD; } if(th[i] == 0 && ah[i] != 0){ if(t[i] < ah[i]){ cout << 0 << endl; return 0; } } if(th[i] != 0 && ah[i] == 0){ if(a[i] < th[i]){ cout << 0 << endl; return 0; } } if(th[i] != 0 && ah[i] != 0){ if(th[i] != ah[i]){ cout << 0 << endl; return 0; } } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | monman53 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1332 Byte |
Status | AC |
Exec Time | 24 ms |
Memory | 3456 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 | 24 ms | 3456 KB |
1_009.txt | AC | 21 ms | 3456 KB |
1_010.txt | AC | 22 ms | 3456 KB |
1_011.txt | AC | 23 ms | 3456 KB |
1_012.txt | AC | 22 ms | 3456 KB |
1_013.txt | AC | 23 ms | 3456 KB |
1_014.txt | AC | 22 ms | 3456 KB |
1_015.txt | AC | 23 ms | 3456 KB |
1_016.txt | AC | 22 ms | 3456 KB |
1_017.txt | AC | 22 ms | 3456 KB |
1_018.txt | AC | 21 ms | 3456 KB |
1_019.txt | AC | 20 ms | 3456 KB |
1_020.txt | AC | 19 ms | 3456 KB |