Submission #1330777
Source Code Expand
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=100003;
const ll LINF=100000000000000000;
ll ub[MAX_N],det[MAX_N],t[MAX_N],a[MAX_N];
int main(){
int N;
cin >> N ;
REP(i,1,N+1) scanf("%lld",&t[i]);
REP(i,0,N) scanf("%lld",&a[i]);
t[0]=0;
a[N]=LINF;
fill(det,det+N,0);
fill(ub,ub+N,LINF);
bool ok=true;
rep(i,N){
if(t[i+1]!=t[i]) det[i]=t[i+1];
else ub[i]=t[i+1];
}
for(int i=N-1;i>=0;i--){
if(a[i+1]!=a[i]){
if(det[i]!=0 && det[i]!=a[i]){
ok=false;
break;
}
else det[i]=a[i];
}else{
ub[i]=min(ub[i],a[i]);
}
}
rep(i,N){
if(det[i]>ub[i]){
ok=false;
break;
}
}
if(!ok) cout << "0" << endl;
ll cnt=1;
rep(i,N){
if(det[i]==0){
cnt=(cnt*ub[i])%mod;
}
}
if(ok) cout << cnt << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Two Alpinists |
User |
kurarrr |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1398 Byte |
Status |
AC |
Exec Time |
26 ms |
Memory |
3328 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:34:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i,1,N+1) scanf("%lld",&t[i]);
^
./Main.cpp:35:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i,0,N) scanf("%lld",&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 |
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 |
26 ms |
3328 KB |
1_009.txt |
AC |
23 ms |
3328 KB |
1_010.txt |
AC |
24 ms |
3328 KB |
1_011.txt |
AC |
26 ms |
3328 KB |
1_012.txt |
AC |
25 ms |
3328 KB |
1_013.txt |
AC |
25 ms |
3328 KB |
1_014.txt |
AC |
25 ms |
3328 KB |
1_015.txt |
AC |
25 ms |
3328 KB |
1_016.txt |
AC |
25 ms |
3328 KB |
1_017.txt |
AC |
25 ms |
3328 KB |
1_018.txt |
AC |
24 ms |
3328 KB |
1_019.txt |
AC |
23 ms |
3328 KB |
1_020.txt |
AC |
22 ms |
3328 KB |