제출 #406061

#제출 시각아이디문제언어결과실행 시간메모리
406061maomao90The short shank; Redemption (BOI21_prison)C++17
컴파일 에러
0 ms0 KiB
#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 75005 int n, d, t; int ti[MAXN]; int cost[MAXN][MAXN]; ll dp[MAXN][MAXN]; void dnc(int i, int lo, int hi, int optl, int optr) { if (lo > hi) return; int j = lo + hi >> 1; int opt = -1; dp[i][j] = LINF; REP (k, optl, min(optr + 1, j)) { if (dp[i][j] > dp[i - 1][k] + cost[k + 1][j]) { dp[i][j] = dp[i - 1][k] + cost[k + 1][j]; opt = k; } } dnc(i, lo, j - 1, optl, opt); dnc(i, j + 1, hi, opt, optr); } int main() { scanf("%d%d%d", &n, &d, &t); REP (i, 1, n + 1) { scanf("%d", &ti[i]); } REP (i, 1, n + 1) { ll r = -1; int cur = 0; REP (j, i, n + 1) { if (t >= ti[j]) mxto(r, t - ti[j] + j); if (r >= j) cur++; cost[i][j] = cur; } } REP (i, 1, n + 1) { dp[0][i] = cost[1][i]; } REP (i, 1, d + 1) { dnc(i, 1, n, 1, n); } printf("%lld\n", dp[d][n]); return 0; }

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

prison.cpp: In function 'void dnc(int, int, int, int, int)':
prison.cpp:34:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |  int j = lo + hi >> 1;
      |          ~~~^~~~
prison.cpp: In function 'int main()':
prison.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  scanf("%d%d%d", &n, &d, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
prison.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   scanf("%d", &ti[i]);
      |   ~~~~~^~~~~~~~~~~~~~
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status