제출 #1166096

#제출 시각아이디문제언어결과실행 시간메모리
1166096dzhoz0K개의 묶음 (IZhO14_blocks)C++20
0 / 100
37 ms82504 KiB
/* ghmt the cutie :3 UwU */ #include <bits/stdc++.h> using namespace std; #define int long long #define INF 1e18 #define f first #define s second #define pii pair<int, int> #define vi vector<int> const int MOD = 1'000'000'000 + 7; void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #ifdef LOCAL freopen("inp.txt", "r", stdin); freopen("out.txt", "w", stdout); #else if (!name.empty()) { freopen((name + ".INP").c_str(), "r", stdin); freopen((name + ".OUT").c_str(), "w", stdout); } #endif } const int MAXN = 1e5, MAXK = 100; int n, k; int a[MAXN + 5]; int dp[MAXN + 5][MAXK + 5]; void solve() { cin >> n >> k; for(int i = 1; i <= n; i++) cin >> a[i]; memset(dp, 0, sizeof(dp)); for(int i = 1; i <= n; i++) { for(int j = 1; j <= k; j++) { dp[i][j] = INF; } } sort(a + 1, a + n + 1); int res = INF; for(int i = 1; i <= n; i++) { dp[i][1] = a[i]; for(int j = 2; j <= min(i, k); j++) { for(int l = j - 1; l < i; l++) { dp[i][j] = min(dp[i][j], dp[l][j - 1] + a[i]); } } } cout << dp[n][k] << '\n'; } signed main() { setIO(); int t = 1; // cin >> t; while (t--) solve(); }

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

blocks.cpp: In function 'void setIO(std::string)':
blocks.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen((name + ".INP").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
blocks.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen((name + ".OUT").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...