제출 #976655

#제출 시각아이디문제언어결과실행 시간메모리
976655thegamercoder19수열 (APIO14_sequence)C++14
50 / 100
2045 ms16476 KiB
/* Coded by thegamercoder Happy Competition and Hacking */ #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #define M_PI 3.14159265358979323846 #define FILER 0 using ll = long long; using ull = unsigned long long; using ld = long double; const ll MOD = pow(10, 9) + 7; const ll INFL = 0x3f3f3f3f3f3f3f3f; const ull INFUL = 0x3f3f3f3f3f3f3f3f; const ll INFT = 0x3f3f3f3f; const ll MAX = 401; const ll MODD = 998244353; const ll BL = 1; const double EPS = 1e-10; #define V vector #define pll pair<ll, ll> #define pull2 pair<ull,ull> #define MS multiset #define M map #define Q queue #define PQ priority_queue #define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c) #define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c) #define FORA(a,i) for(auto i : a) #define FORAE(a,i) for(auto &i : a) #define all(v) v.begin(),v.end() #define sorta(a) sort(all(a)) #define sortd(a) sort(all(a), greater<ll>()) #define setp(x) setprecision(x)<<fixed #define RET return #define log(a,b) log(b)/log(a) #define WH(s) while(s) #define WHI(t) WH(t--) #define YES cout<<"YES"<<endl; #define NO cout<<"NO"<<endl; #define Yes cout<<"Yes"<<endl; #define No cout<<"No"<<endl; #define YESNO(s) cout<<(s?"YES":"NO")<<endl; #define YesNo(s) cout<<(s?"Yes":"No")<<endl; #define TYP 0 using namespace std; V<ll> a, pf, res; V<V<ll>> dp; ll n, k; void solve() { cin >> n >> k; a.resize(n + 1); pf.resize(n + 1); FOR(ll, i, 1, n + 1, 1)cin >> a[i], pf[i] = pf[i - 1] + a[i]; dp.resize(n + 1, V<ll>(k + 1)); //FOR(ll, i, 1, n + 1, 1)dp[i][0] = pf[i]; FOR(ll, j, 1, k + 1, 1) FOR(ll, i, 1, n + 1, 1) FOR(ll, c, 1, i, 1) dp[i][j] = max(dp[i][j], dp[i - c][j - 1] + pf[i - c] * (pf[i] - pf[i - c])); cout << dp[n][k] << endl; ll i = n, j = k; WH(j) { FOR(ll,c,1,i,1) if (dp[i - c][j - 1] + pf[i - c] * (pf[i] - pf[i - c]) == dp[i][j]) { j--; i -= c; res.push_back(i); break; } } reverse(all(res)); FORA(res, x)cout << x << ' '; } void init() { if (FILER) { freopen("pump.in", "r", stdin); freopen("pump.out", "w", stdout); } } void handle() { init(); ll t = 1; if (TYP)cin >> t; WHI(t)solve(); } int main() { IOF handle(); RET 0; }

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

sequence.cpp: In function 'void init()':
sequence.cpp:87:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |         freopen("pump.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sequence.cpp:88:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   88 |         freopen("pump.out", "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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...