Submission #1688880
Source Code Expand
#include<bits/stdc++.h> #define range(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,b) for(int i = 0; i < (b); i++) #define all(a) (a).begin(), (a).end() #define show(x) cerr << #x << " = " << (x) << endl; //const int INF = 1e8; using namespace std; const int M = 1000000007; int main(){ int n; cin >> n; vector<long long> t(n + 2), a(n + 2); rep(i,n) cin >> t[i + 1]; rep(i,n) cin >> a[i + 1]; t[0] = -1; a[n + 1] = -1; vector<long long> T(n + 2, 0); vector<long long> k(n + 2); rep(i,n){ if(t[i] != t[i + 1]){ T[i + 1] = true; } k[i + 1] = t[i + 1]; } T[1] = true; //rep(i,n + 2){ cout << k[i] << ' '; }cout << endl; for(int i = n + 1; i >= 2; i--){ if(T[i - 1]) continue; if(a[i] != a[i - 1]){ T[i - 1] = true; } k[i - 1] = min(k[i - 1], a[i - 1]); } T[n] = true; //rep(i,n + 2){ cout << k[i] << ' '; }cout << endl; int cur = 0; range(i,1,n + 1){ cur = k[i]; if(cur > t[i]){ cout << 0 << endl; return 0; } } cur = 0; for(int i = n; i >= 1; i--){ cur = k[i]; if(cur > a[i]){ cout << 0 << endl; return 0; } } long long ans = 1; range(i,1,n + 1){ if(not T[i]) (ans *= k[i]) %= M; } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | noy72 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1257 Byte |
Status | AC |
Exec Time | 99 ms |
Memory | 3328 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 | 99 ms | 3328 KB |
1_009.txt | AC | 80 ms | 3328 KB |
1_010.txt | AC | 86 ms | 3328 KB |
1_011.txt | AC | 95 ms | 3328 KB |
1_012.txt | AC | 89 ms | 3328 KB |
1_013.txt | AC | 89 ms | 3328 KB |
1_014.txt | AC | 88 ms | 3328 KB |
1_015.txt | AC | 90 ms | 3328 KB |
1_016.txt | AC | 85 ms | 3328 KB |
1_017.txt | AC | 80 ms | 3328 KB |
1_018.txt | AC | 81 ms | 3328 KB |
1_019.txt | AC | 70 ms | 3328 KB |
1_020.txt | AC | 64 ms | 3328 KB |