제출 #1181774

#제출 시각아이디문제언어결과실행 시간메모리
1181774pythontestGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
100 / 100
18 ms4936 KiB
#include <iostream>
#include <vector>
using namespace std;
constexpr int N=2e5+10;
long long prefiks[N],sufiks[N];
long long dane[N],roz[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&dane[i]);
    for(int i=1;i<n;i++) roz[i]=dane[i+1]-dane[i];
    for(int i=1;i<n;i++) prefiks[i]=max(1-roz[i],0ll)+prefiks[i-1];
    long long wyn=1e18,v=0;
    roz[n]=-1;
    for(int i=n;i>0;i--){
        v-=min(0ll,-1-roz[i]);
        wyn=min(wyn,max(v,prefiks[i-1]));
    }
    printf("%lld",wyn);
    return 0;
}

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

Main.cpp: In function 'int main()':
Main.cpp:10:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   10 |     for(int i=1;i<=n;i++) scanf("%d",&dane[i]);
      |                                  ~^  ~~~~~~~~
      |                                   |  |
      |                                   |  long long int*
      |                                   int*
      |                                  %lld
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
Main.cpp:10:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(int i=1;i<=n;i++) scanf("%d",&dane[i]);
      |                           ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...