제출 #376259

#제출 시각아이디문제언어결과실행 시간메모리
376259joelauBigger segments (IZhO19_segments)C++14
27 / 100
1578 ms35712 KiB
#include <bits/stdc++.h> using namespace std; int N,dp[3001][3001]; long long A[500001]; int main() { scanf("%d", &N); A[0] = 0; for (int i = 1; i <= N; ++i) { scanf("%lld", &A[i]); A[i] += A[i-1]; } memset(dp,-1,sizeof(dp)); for (int i = 0; i < N; ++i) { dp[0][i] = 1; for (int j = 1; j <= i; ++j) for (int k = 0; k < j; ++k) if (A[i+1] - A[j] >= A[j] - A[k] && dp[k][j-1] != -1) dp[j][i] = max(dp[j][i],dp[k][j-1]+1); } int ans = 0; for (int i = 0; i < N; ++i) ans = max(ans,dp[i][N-1]); printf("%d", ans); return 0; }

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

segments.cpp: In function 'int main()':
segments.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
segments.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         scanf("%lld", &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...