#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define S second
#define F first
#define inputt freopen("input.txt","r",stdin);freopen("outut.txt","w",stdout);
#define ahah ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=1e6+7;
const int MOD=1e9+7;
int a[N];
signed main() {
ahah
int n,m;
cin >> n >> m;
for(int i = 1 ; i <= m ; i++){
cin >> a[i];
}
int ans=-1;
for(int l = 1 ; l <= m ; l++){
for(int r = l ; r <= m ; r++){
int sz=0,mx=0,mn=1e18;
for(int i = l ; i <= r ; i++){
sz++;
mx=max(mx,a[i]);
mn=min(mn,a[i]);
}
ans=max(ans,(mx-mn-sz));
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
548 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
113 ms |
512 KB |
Output is correct |
2 |
Correct |
113 ms |
584 KB |
Output is correct |
3 |
Correct |
115 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
548 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
548 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |