120702024-11-29 07:31:17KissCsongor777Sípálya (55 pont)cpp17Forditási hiba
#include <iostream>

using namespace std;

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+=b-c-1;c+=p;}
        else {p+=c-b+1;b+=c-b+1;}
        if(a<=b){p+=b-a+1;a+=b-a+1;}
        else while(a>b+1){b++; c++; p+=2;}
        if(p<inf)inf=p;
    }
    cout<<inf;
    return 0;
}
Forditási hiba
open /var/local/lib/isolate/412/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];
      |                         ^