12071 | 2024-11-29 07:47:00 | KissCsongor777 | Sípálya (55 pont) | cpp17 | Forditási hiba |
#include <iostream>
using namespace std;
int H[200001];
int main()
{
int N,K,inf=INT_MAX,p=0,a,b,c;
cin>>N>>K;
//int H[N+1];//
for(int i=1; i<=N; i++)cin>>H[i];
for(int i=1; i<=N-2; i++)
{
p=0;
a=H[i];b=H[i+1];c=H[i+2];
if(c<b){p=p+b-c-1;c+=p;}
else {p=p+(c-b+1);b=(c+1);}
if(a<=b){p=p+(b-a+1);a=(b+1);}
else while(a>b+1){b++; c++; p=p+2;}
if(p<inf)inf=p;
}
cout<<inf;
return 0;
}
open /var/local/lib/isolate/421/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:7:17: error: 'INT_MAX' was not declared in this scope
7 | int N,K,inf=INT_MAX,p=0,a,b,c;
| ^~~~~~~
main.cpp:2:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
1 | #include <iostream>
+++ |+#include <climits>
2 |
main.cpp:13:9: error: 'p' was not declared in this scope
13 | p=0;
| ^
main.cpp:14:9: error: 'a' was not declared in this scope
14 | a=H[i];b=H[i+1];c=H[i+2];
| ^
main.cpp:14:16: error: 'b' was not declared in this scope
14 | a=H[i];b=H[i+1];c=H[i+2];
| ^
main.cpp:14:25: error: 'c' was not declared in this scope
14 | a=H[i];b=H[i+1];c=H[i+2];
| ^