#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <array>
#include <iomanip>
#include <fstream>
#include <cstdlib>
using namespace std;
int maxi(int s,int lo,int hi,vector<int>&num,int nodo){
int n=num.size();
if(n==nodo){
return s;
}
int a=min(lo,num[nodo]);
int b=max(hi,num[nodo]);
s=s-hi+b+lo-a-1;
return max(maxi(s,a,b,num,nodo+1),maxi(-1,num[nodo],num[nodo],num,nodo+1));
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
vector<int>num(n+m);
for(int i=0;i<n;i++){
for(int k=0;k<m;k++)cin>>num[i+k];
}
if(n==1){
cout<<maxi(-1,num[0],num[0],num,1);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
356 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |