#include <bits/stdc++.h>
using namespace std;
vector < pair<int,int> > niz; //min i max
int n,a,test;
int mini=1e9;
int main(){
cin>>n;
for(int j=0;j<n;j++){
cin>>a;
niz.push_back(make_pair(a,a));
for(int i=0;i<j;i++){
if(niz[i].first > a)niz[i].first=a;
if(niz[i].second < a)niz[i].second=a;
test=niz[i].second-niz[i].first;
if(test<mini)mini=test;
}
}
cout<<mini;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
1089 ms |
1008 KB |
Time limit exceeded |
6 |
Execution timed out |
1068 ms |
1112 KB |
Time limit exceeded |
7 |
Execution timed out |
1079 ms |
1012 KB |
Time limit exceeded |