CODE FESTIVAL 2016 qual C

Submission #948995

Source codeソースコード

#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

Task問題 C - 二人のアルピニスト / Two Alpinists
User nameユーザ名 imulan
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 997 Byte
File nameファイル名
Exec time実行時間 28 ms
Memory usageメモリ使用量 1024 KB

Compiler messageコンパイルメッセージ

./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]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_000.txt,0_001.txt,0_002.txt,0_003.txt
All 400 / 400 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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