Submission #948995
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
const ll mod=1e9+7;
int main()
{
int n;
scanf(" %d", &n);
vector<int> t(n),a(n);
rep(i,n) scanf(" %d", &t[i]);
rep(i,n) scanf(" %d", &a[i]);
bool ok=(t[n-1]==a[0]);
for(int i=1; i<n; ++i)
{
if(t[i-1]<t[i])
{
if(a[i]<t[i]) ok=false;
}
}
for(int i=n-2; i>=0; --i)
{
if(a[i+1]<a[i])
{
if(t[i]<a[i]) ok=false;
}
}
ll ans=0;
if(ok)
{
ans=1;
for(int i=1; i<n-1; ++i)
{
if(t[i]==t[i-1] && a[i]==a[i+1]) (ans*=min(t[i],a[i]))%=mod;
}
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Two Alpinists |
User |
imulan |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
997 Byte |
Status |
AC |
Exec Time |
28 ms |
Memory |
1024 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:17:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d", &n);
^
./Main.cpp:19:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,n) scanf(" %d", &t[i]);
^
./Main.cpp:20:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,n) scanf(" %d", &a[i]);
^
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 |
3 ms |
256 KB |
0_001.txt |
AC |
3 ms |
256 KB |
0_002.txt |
AC |
3 ms |
256 KB |
0_003.txt |
AC |
3 ms |
256 KB |
1_004.txt |
AC |
3 ms |
256 KB |
1_005.txt |
AC |
3 ms |
256 KB |
1_006.txt |
AC |
3 ms |
256 KB |
1_007.txt |
AC |
3 ms |
256 KB |
1_008.txt |
AC |
28 ms |
1024 KB |
1_009.txt |
AC |
25 ms |
1024 KB |
1_010.txt |
AC |
26 ms |
1024 KB |
1_011.txt |
AC |
27 ms |
1024 KB |
1_012.txt |
AC |
26 ms |
1024 KB |
1_013.txt |
AC |
27 ms |
1024 KB |
1_014.txt |
AC |
26 ms |
1024 KB |
1_015.txt |
AC |
27 ms |
1024 KB |
1_016.txt |
AC |
26 ms |
1024 KB |
1_017.txt |
AC |
26 ms |
1024 KB |
1_018.txt |
AC |
25 ms |
1024 KB |
1_019.txt |
AC |
24 ms |
1024 KB |
1_020.txt |
AC |
23 ms |
1024 KB |