#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 n,m;
vector<pair<int,pair<int,int> > >memo;
int maxi(int nodo,vector<int>&num,int hi,int lo,int c){
if(nodo==num.size())return hi-lo-c;
hi=max(hi,num[nodo]);
lo=min(lo,num[nodo]);
return max(hi-lo-c,max(maxi(nodo+1,num,hi,lo,c+1),maxi(nodo+1,num,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*m+k];
}
cout<<maxi(0,num,num[0],num[0],1);
return 0;
}
Compilation message
maxcomp.cpp: In function 'int maxi(int, std::vector<int>&, int, int, int)':
maxcomp.cpp:19:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | if(nodo==num.size())return hi-lo-c;
| ~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |