Submission #1754662
Source Code Expand
#include<iostream> #include<cstdio> #include<vector> #include<string> #include<functional> #include<queue> #include <iomanip> #include<map> #include<limits> #include<cmath> #include<algorithm> #include<bitset> #include<utility> #include<complex> #include<cstdlib> #include<set> #include<cctype> #define DBG cerr << '!' << endl; #define REP(i,n) for(int (i) = (0);(i) < (n);++i) #define rep(i,s,g) for(int (i) = (s);(i) < (g);++i) #define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i)) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;} #define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;} #define ALL(v) v.begin(),v.end() using namespace std; typedef long long ll; typedef vector<int> iv; typedef vector<iv> iiv; typedef vector<string> sv; #define INF 1000000007; bool lock[100010]; ll dp[100010]; ll a[100010],b[100010]; int main() { int n;cin >> n; REP(i,n)dp[i] = INF; REP(i,n)cin >> a[i]; REP(i,n)cin >> b[i]; ll now = 0; REP(i,n) { if(a[i] > now) { lock[i] = true; now = a[i]; } dp[i] = min(dp[i],now); } now = 0; REP(i,n) { if(b[n-i-1] > now) { if(lock[n-i-1] && b[n-i-1] != dp[n-i-1]) { cout << 0 << endl; return 0; } lock[n-i-1] = true; } now = b[n-i-1]; dp[n-i-1] = min(dp[n-i-1],now); } ll ans = 1; REP(i,n) { if(!lock[i]) { ans = (ans*dp[i]) % INF; } } //SHOW1d(dp,n); //SHOW1d(lock,n); cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | seica |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1726 Byte |
Status | WA |
Exec Time | 86 ms |
Memory | 2688 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 86 ms | 2560 KB |
1_009.txt | AC | 71 ms | 2688 KB |
1_010.txt | AC | 76 ms | 2688 KB |
1_011.txt | AC | 80 ms | 2688 KB |
1_012.txt | AC | 77 ms | 2688 KB |
1_013.txt | AC | 79 ms | 2688 KB |
1_014.txt | AC | 80 ms | 2688 KB |
1_015.txt | AC | 80 ms | 2688 KB |
1_016.txt | AC | 77 ms | 2688 KB |
1_017.txt | AC | 74 ms | 2688 KB |
1_018.txt | WA | 72 ms | 2688 KB |
1_019.txt | AC | 64 ms | 2560 KB |
1_020.txt | WA | 60 ms | 2560 KB |