제출 #465007

#제출 시각아이디문제언어결과실행 시간메모리
465007DeepessonGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
32 ms3780 KiB
#include <bits/stdc++.h> int N; bool valido(long long* seq) { bool cresce=true; long long last=0; for(int i=0;i!=N;++i){ if(seq[i]>last){ if(!cresce)return false; }else if(seq[i]<last){ if(cresce)cresce=false; }else { return false; } last=seq[i]; } return true; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); std::cin>>N; long long array[N]; for(auto&x:array)std::cin>>x; if(N==2){ if(array[0]==array[1]){ printf("1\n");return 0; }else printf("0\n");return 0; } long long cur1 = 1,cur2=N-2,soma=0; long long total=0; while(cur1!=cur2){ if(array[cur1-1]<array[cur1]){ ++cur1; array[cur1]+=soma; continue; } if(array[cur2+1]<array[cur2]){ --cur2; array[cur2]+=soma; continue; } long long to_cur1 = (array[cur1-1]+1LL)-array[cur1]; long long to_cur2 = (array[cur2+1]+1LL)-array[cur2]; long long res = std::min(to_cur1,to_cur2); array[cur1]+=res; array[cur2]+=res; soma+=res; total+=res; } array[cur1]-=soma; if(valido(array))goto fim;{ long long pico_cresce = (array[cur1-1]+1LL)-array[cur1]; long long pico_desce = (array[cur2+1]+1LL)-array[cur2]; //std::cout<<pico_cresce << " " << pico_desce << "\n"; total+=std::min(pico_cresce,pico_desce); array[cur1]+=std::min(pico_cresce,pico_desce); while(!valido(array)){ ++array[cur1]; ++total; }} fim: std::cout<<total<<"\n"; }

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

Main.cpp: In function 'int main()':
Main.cpp:53:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   53 |     if(valido(array))goto fim;{
      |     ^~
Main.cpp:53:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   53 |     if(valido(array))goto fim;{
      |                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...