제출 #287853

#제출 시각아이디문제언어결과실행 시간메모리
287853dantoh000Bigger segments (IZhO19_segments)C++14
13 / 100
1 ms512 KiB
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
int n;
int a[500005];
ii dp[500005];
ll p[500005];
int main(){
    scanf("%d",&n);
    for (int i = 1 ; i <= n; i++){
        scanf("%d",&a[i]);
        p[i] = p[i-1]+a[i];
    }
    dp[0] = ii(0,0);
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < i; j++){
            if (p[i]-p[j] >= dp[j].se){
                if (dp[i].fi < dp[j].fi+1 || (dp[i].fi == dp[j].fi+1 && dp[i].se > p[i]-p[j]) ){
                    dp[i] = {dp[j].fi+1, p[i]-p[j]};
                }
            }
        }
    }
    printf("%d\n",dp[n].fi);
}

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

segments.cpp: In function 'int main()':
segments.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
segments.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...