제출 #344634

#제출 시각아이디문제언어결과실행 시간메모리
344634NurlykhanBigger segments (IZhO19_segments)C++17
37 / 100
20 ms512 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = (int)3000 + 10; const int mod = (int)1e9 + 7; int n; int a[N]; ll pref[N]; ll get_sum(int l, int r) { return pref[r] - pref[l - 1]; } pair<int, int> dp[N]; int main() { // freopen("in.txt", "r", stdin); scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); pref[i] = pref[i - 1] + a[i]; } for (int i = 1; i <= n; i++) { dp[i] = make_pair(1, 1); for (int j = 1; j < i; j++) { int left = dp[j].second; if (get_sum(left, j) <= get_sum(j + 1, i)) { dp[i] = max(dp[i], make_pair(dp[j].first + 1, j + 1)); } } } cout << dp[n].first; return 0; }

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

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