Submission #96382

# Submission time Handle Problem Language Result Execution time Memory
96382 2019-02-08T23:30:31 Z DiegoGarcia Pismo (COCI18_pismo) C++11
70 / 70
20 ms 1016 KB
#include <bits/stdc++.h>
#define optimiza_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ft first
#define sd second
#define ll long long
#define ld long double
#define ull unsigned long long
#define INF 1E5
#define LINF 1E18
using namespace std;

const ll maxn = 1e5+3;
ll n, v[maxn], ans;

int main()
{
    scanf("%lld",&n);
    for( ll i=0; i<n; i++ ){
        scanf("%lld",&v[i]);
    }
    ans = LINF;
    for( ll i=0; i<n; i++ ){
        if( i > 0 && v[i] >= v[i-1] )
            ans = min( ans, v[i] - v[i-1] );
        if( i < n-1 && v[i] >= v[i+1] )
            ans = min( ans, v[i] - v[i+1] );
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

pismo.cpp: In function 'int main()':
pismo.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
pismo.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&v[i]);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 20 ms 1016 KB Output is correct
6 Correct 17 ms 1016 KB Output is correct
7 Correct 17 ms 1016 KB Output is correct