Submission #1753631
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
int main() {
int n, i, j;
cin >> n;
vl a(n), t(n);
for (i = 0; i < n; i++) {
cin >> t[i];
}
for (i = 0; i < n; i++) {
cin >> a[i];
}
vector<pll> a2(n), t2(n);
ll M = -1;
for (i = 0; i < n; i++) {
if (t[i] > M) {
M = t[i];
t2[i] = pll(M, M);
} else {
t2[i] = pll(1, M);
}
}
M = -1;
for (i = n-1; i >= 0; i--) {
if (a[i] > M) {
M = a[i];
a2[i] = pll(M, M);
} else {
a2[i] = pll(1, M);
}
}
ll ans = 1;
for (i = 0; i < n; i++) {
if (a2[i].second < t2[i].first || t2[i].second < a2[i].first) {
ans *= 0;
}
else {
ans = ans * (min(a2[i].second, t2[i].second) - max(a2[i].first, t2[i].first) + 1) % MOD;
}
}
cout << ans << endl;
}
Submission Info
Submission Time |
|
Task |
C - Two Alpinists |
User |
fuppy0716 |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1576 Byte |
Status |
AC |
Exec Time |
87 ms |
Memory |
4992 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 |
87 ms |
4992 KB |
1_009.txt |
AC |
72 ms |
4992 KB |
1_010.txt |
AC |
77 ms |
4992 KB |
1_011.txt |
AC |
81 ms |
4992 KB |
1_012.txt |
AC |
79 ms |
4992 KB |
1_013.txt |
AC |
81 ms |
4992 KB |
1_014.txt |
AC |
81 ms |
4992 KB |
1_015.txt |
AC |
82 ms |
4992 KB |
1_016.txt |
AC |
79 ms |
4992 KB |
1_017.txt |
AC |
75 ms |
4992 KB |
1_018.txt |
AC |
73 ms |
4992 KB |
1_019.txt |
AC |
64 ms |
4992 KB |
1_020.txt |
AC |
66 ms |
4992 KB |