Submission #1689149
Source Code Expand
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define loop(i,x,n) for(int i=x;i<n;i++) #define pb push_back #define mp make_pair #define fir first #define sec second #define int long long using namespace std; const int MOD=1000000007; const int INF=1000000009; signed main(){ int n; cin>>n; vector<int> t(n),a(n); rep(i,n)cin>>t[i]; rep(i,n)cin>>a[i]; int tmax=(-1)*INF,amax=(-1)*INF; int ttop,atop; vector<int> hoge(n); rep(i,n){ if(tmax<t[i]){ tmax=t[i]; ttop=i; } if(amax<a[n-1-i]){ amax=a[n-1-i]; atop=n-1-i; } if(t[i]<a[i])hoge[i]=t[i]; if(t[n-1-i]>a[n-1-i])hoge[n-1-i]=a[n-1-i]; if(t[i]==a[i])hoge[i]=t[i]; } if(tmax!=amax){ cout<<0<<endl; return 0; } int ans=1,minall=hoge[0]; if(hoge[0]>hoge[n-1])minall=hoge[n-1]; rep(i,ttop){ if(i==0)continue; if(hoge[i]==hoge[i-1]){ ans*=hoge[i]; ans%=MOD; } } for(int i=n-1;i>atop;i--){ if(i==n-1)continue; if(hoge[i]==hoge[i+1]){ ans*=hoge[i]; ans%=MOD; } } int sub=atop-ttop-1; rep(i,sub){ ans*=tmax; ans%=MOD; } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | fuu32 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1233 Byte |
Status | WA |
Exec Time | 88 ms |
Memory | 2560 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 | WA | 1 ms | 256 KB |
1_006.txt | WA | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 88 ms | 2560 KB |
1_009.txt | AC | 71 ms | 2560 KB |
1_010.txt | AC | 76 ms | 2560 KB |
1_011.txt | AC | 81 ms | 2560 KB |
1_012.txt | WA | 79 ms | 2560 KB |
1_013.txt | AC | 80 ms | 2560 KB |
1_014.txt | WA | 81 ms | 2560 KB |
1_015.txt | AC | 81 ms | 2560 KB |
1_016.txt | WA | 79 ms | 2560 KB |
1_017.txt | AC | 75 ms | 2560 KB |
1_018.txt | WA | 73 ms | 2560 KB |
1_019.txt | AC | 64 ms | 2560 KB |
1_020.txt | WA | 61 ms | 2560 KB |