제출 #532492

#제출 시각아이디문제언어결과실행 시간메모리
532492Nanashi_PandaGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
33 ms4548 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native") #define jizz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long using namespace std; ll n; ll a[200005]; ll mi[200005] = {0}; ll nigsum, sum; int main() { scanf("%lld", &n); for(ll i = 0; i < n; i++){ scanf("%lld", a+i); if(i>0){ mi[i] = a[i]-a[i-1]; if(mi[i]>0)sum+=mi[i]+1; else if(mi[i]<0) nigsum-=mi[i]-1; else{ sum++;nigsum++; } } } ll ans =1e9; ll nnigsum=0,nsum = 0; ans = sum; for(ll i = 1; i < n; i++){ if(mi[i]>0)nsum+=mi[i]+1; else if(mi[i]<0) nnigsum-=mi[i]-1; else{ nsum++;nnigsum++; } ans = min(ans, max(nnigsum, sum-nsum)); // printf("%lld %lld %lld\n", nnigsum, sum, nsum); } printf("%lld", ans); return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%lld", a+i);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...