제출 #1281930

#제출 시각아이디문제언어결과실행 시간메모리
1281930vuquangsangStove (JOI18_stove)C++20
20 / 100
1096 ms14908 KiB
#include <bits/stdc++.h> using namespace std; #define el "\n" #define FOR(i,a,b) for(int i = (a), _b = (b); i <= _b; i++) #define FORD(i,a,b) for(int i = (a), _b = (b); i >= _b; i--) #define pb push_back #define fi first #define se second #define all(x) x.begin(),x.end() #define lg(x) __lg(x) #define alla(a,n) a+1,a+n+1 #define ll long long template <class T> bool maxi(T &x, T y) { if(x < y) { x = y ; return true ;} return false;} template <class T> bool mini(T &x, T y) { if(x > y) { x = y ; return true ;} return false;} const int N = 1e5 + 2; const ll inf = 1e16 + 2; int n, k, a[N]; void inp() { cin >> n >> k; FOR(i, 1, n) cin >> a[i]; } /* Try your best No regrets */ namespace subtask_1 { ll dp[5005][5005]; ll st[4 * N]; void slv() { sort(a + 1, a + n + 1); FOR(i, 0, n) FOR(j, 0, k) dp[i][j] = inf; dp[0][0] = 0; FOR(j, 1, k) { // build(1, 0, n, j - 1); FOR(i, 1, n) { FOR(t, 1, i) mini(dp[i][j], dp[t - 1][j - 1] + a[i] + 1 - a[t]); } } // FOR(i, 1, n) { // FOR(j, 1, k) { // cout << dp[i][j] << " "; // } cout << el; // } ll ans = inf; FOR(i, 1, k) mini(ans, dp[n][i]); cout << ans; } } /* Code slowly, think carefully */ main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define __Azul__ "stove" if(fopen(__Azul__".inp", "r")) { freopen(__Azul__".inp", "r", stdin); freopen(__Azul__".out", "w", stdout); } bool qs = 0; int T = 1; if(qs) cin >> T; while(T--) { inp(); subtask_1::slv(); } cerr << "\nTime" << 0.001 * clock() << "s "; return 0; }

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

stove.cpp:66:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   66 | main()
      | ^~~~
stove.cpp: In function 'int main()':
stove.cpp:72:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen(__Azul__".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen(__Azul__".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...