제출 #850861

#제출 시각아이디문제언어결과실행 시간메모리
850861dungzGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
컴파일 에러
0 ms0 KiB
//#pragma GCC optimize ("O2") #include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define endl '\n' #define task "task" #define task "task" #define prll pair<ll,ll> #define pb push_back #define ld long double const ll MIN=-1e18,MAX=1e18,MOD=1e9+7,nmax=200005; int main(){ //freopen (task".inp", "r", stdin); //freopen (task".out", "w", stdout); ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } h1[1]=a[1]; for(int i=2;i<=n;i++) { if(a[i]<=a[i-1]) { cost1[i]=cost1[i-1]+a[i-1]-a[i]+1; } else { cost1[i]=cost1[i-1]; } } for(int i=n-1;i>=1;i--) { if(a[i]<=a[i+1]) { cost2[i]=cost2[i+1]+a[i+1]-a[i]+1; } else { cost2[i]=cost2[i+1]; } } ll ans=MAX; for(int i=0;i<=n;i++) { ans=min(ans,max(cost1[i],cost2[i+1])); } cout<<ans; } /* 8 12 2 34 85 4 91 29 85 */

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:22:8: error: 'a' was not declared in this scope
   22 |   cin>>a[i];
      |        ^
Main.cpp:24:2: error: 'h1' was not declared in this scope; did you mean 'y1'?
   24 |  h1[1]=a[1];
      |  ^~
      |  y1
Main.cpp:24:8: error: 'a' was not declared in this scope
   24 |  h1[1]=a[1];
      |        ^
Main.cpp:29:4: error: 'cost1' was not declared in this scope
   29 |    cost1[i]=cost1[i-1]+a[i-1]-a[i]+1;
      |    ^~~~~
Main.cpp:33:4: error: 'cost1' was not declared in this scope
   33 |    cost1[i]=cost1[i-1];
      |    ^~~~~
Main.cpp:40:4: error: 'cost2' was not declared in this scope; did you mean 'cosf32'?
   40 |    cost2[i]=cost2[i+1]+a[i+1]-a[i]+1;
      |    ^~~~~
      |    cosf32
Main.cpp:44:4: error: 'cost2' was not declared in this scope; did you mean 'cosf32'?
   44 |    cost2[i]=cost2[i+1];
      |    ^~~~~
      |    cosf32
Main.cpp:50:19: error: 'cost1' was not declared in this scope
   50 |   ans=min(ans,max(cost1[i],cost2[i+1]));
      |                   ^~~~~
Main.cpp:50:28: error: 'cost2' was not declared in this scope; did you mean 'cosf32'?
   50 |   ans=min(ans,max(cost1[i],cost2[i+1]));
      |                            ^~~~~
      |                            cosf32