제출 #376330

#제출 시각아이디문제언어결과실행 시간메모리
376330maomao90Bigger segments (IZhO19_segments)C++14
0 / 100
1 ms364 KiB
// https://oj.uz/problem/view/IZhO19_segments #include <bits/stdc++.h> using namespace std; #define mnto(x, y) x = min(x, (__typeof__(x)) y) #define mxto(x, y) x = max(x, (__typeof__(x)) y) #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; #define MT make_tuple typedef tuple<int, int, int> iii; #define ALL(_a) _a.begin(), _a.end() #define pb emplace_back typedef vector<int> vi; typedef vector<ii> vii; #define INF 1000000005 #define LINF 1000000000000000005 #define MOD 1000000007 #define MAXN 3005 int n; int a[MAXN]; int dp[MAXN][MAXN], ans; ll sum(int s, int e) { return (ll) a[e] - (s == 0 ? 0ll : (ll) a[s - 1]); } int main() { scanf("%d", &n); REP (i, 0, n) scanf("%d", &a[i]); REP (i, 1, n) { a[i] += a[i - 1]; } REP (i, 0, n) REP (j, 0, n) dp[i][j] = -INF; ans = 1; REP (i, 0, n) { dp[i][0] = 1; REP (j, 1, i + 1) { RREP (k, j - 1, 0) { if (sum(k, j - 1) > sum(j, i)) break; mxto(dp[i][j], dp[k][j - 1] + 1); } // printf("%d %d: %d\n", j, i, dp[i][j]); } } REP (i, 0, n) { mxto(ans, dp[i][n - 1]); } printf("%d\n", ans); return 0; }

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

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