提出 #945214
ソースコード 拡げる
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define all(v) (v).begin(),(v).end()
#define endl '\n'
#define int long long
const int INF = (1 << 30);
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
bool hcao[(int)1e5+5] = {};
bool hctk[(int)1e5+5] = {};
bool hc[(int)1e5+5] = {};
void solve(){
int n;
cin >> n;
vi tk(n), ao(n), hoge(n);
REP(i,n){
cin >> tk[i];
if(i && tk[i] != tk[i-1]) hctk[i] = true;
}
REP(i,n){
cin >> ao[i];
if(i && ao[i] != ao[i-1]){
hcao[i] = true;
}
}
hcao[0]=hcao[n]=hctk[0]=hctk[n]=true;
REP(i,n){
hoge[i] = min(tk[i], ao[i]);
if(i && hoge[i] != hoge[i-1]){
hc[i] = true;
}
}
int ans = 1;
REP(i,n){
if(hctk[i] && hcao[i+1]){
if(tk[i] != ao[i]){
cout << 0 << endl;
return;
}
}
else if(hctk[i] && !hcao[i+1]){
if(tk[i] > ao[i]){
cout << 0 << endl;
return;
}
}
else if(!hctk[i] && hcao[i+1]){
if(tk[i] < ao[i]){
cout << 0 << endl;
return;
}
}
else{
ans *= hoge[i];
ans %= (int)1e9+7;
}
}
cout << ans << endl;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - 二人のアルピニスト |
| ユーザ | Iruyan_Zak |
| 言語 | C++14 (GCC 5.4.1) |
| 得点 | 400 |
| コード長 | 1588 Byte |
| 結果 | AC |
| 実行時間 | 28 ms |
| メモリ | 2816 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0_000.txt | AC | 3 ms | 256 KiB |
| 0_001.txt | AC | 3 ms | 256 KiB |
| 0_002.txt | AC | 3 ms | 256 KiB |
| 0_003.txt | AC | 3 ms | 256 KiB |
| 1_004.txt | AC | 3 ms | 256 KiB |
| 1_005.txt | AC | 3 ms | 256 KiB |
| 1_006.txt | AC | 3 ms | 256 KiB |
| 1_007.txt | AC | 3 ms | 256 KiB |
| 1_008.txt | AC | 28 ms | 2560 KiB |
| 1_009.txt | AC | 25 ms | 2816 KiB |
| 1_010.txt | AC | 26 ms | 2688 KiB |
| 1_011.txt | AC | 27 ms | 2688 KiB |
| 1_012.txt | AC | 27 ms | 2816 KiB |
| 1_013.txt | AC | 27 ms | 2816 KiB |
| 1_014.txt | AC | 27 ms | 2816 KiB |
| 1_015.txt | AC | 27 ms | 2688 KiB |
| 1_016.txt | AC | 26 ms | 2816 KiB |
| 1_017.txt | AC | 26 ms | 2688 KiB |
| 1_018.txt | AC | 25 ms | 2688 KiB |
| 1_019.txt | AC | 24 ms | 2688 KiB |
| 1_020.txt | AC | 22 ms | 2688 KiB |