Submission #884141

# Submission time Handle Problem Language Result Execution time Memory
884141 2023-12-06T16:06:31 Z vjudge1 Pismo (COCI18_pismo) C++17
70 / 70
11 ms 1336 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    const int lim=2e5+100;
#else
    const int lim=2e3+100;
#endif

#include "bits/stdc++.h"
using namespace std;

#define int int64_t
#define pb push_back

const int mod=1e9+7;
using pii=pair<int,int>;

inline void solve(){
    int n;
    cin>>n;
    int prev,now;
    cin>>prev;
    int ans=LLONG_MAX;
    for(int i=1;i<n;i++){
        cin>>now;
        ans=min(ans,max(prev,now)-min(now,prev));
        swap(now,prev);
    }
    cout<<ans<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
#else
    //freopen("grass.in","r",stdin);
    //freopen("grass.out","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 1116 KB Output is correct
6 Correct 11 ms 1336 KB Output is correct
7 Correct 7 ms 1328 KB Output is correct