제출 #780954

#제출 시각아이디문제언어결과실행 시간메모리
780954teokakabadze수열 (APIO14_sequence)C++17
0 / 100
6 ms2644 KiB
#include<bits/stdc++.h> #define f first #define s second #define pb push_back #define int long long #define N 300005 #define pii pair<int, int> #define piii pair<int, pii> using namespace std; int n, k, i, j, a[N], t, mx, f[N], p[N], s[N], b, ans; main() { std::ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for(i = 0; i < n; i++) cin >> a[i]; while(k--) { t = mx = 0; for(i = 0; i < n; i++) { if(f[i]) t = 0; t += a[i]; p[i] = t; } t = 0; for(i = n - 1; i >= 0; i--) { t += a[i]; s[i] = t; if(f[i]) t = 0; } for(i = 0; i < n - 1; i++) if(!f[i + 1] && p[i] * s[i + 1] >= mx) mx = p[i] * s[i + 1], b = i + 1; f[b] = 1, ans += mx; //cout << b << ' ' << mx << '\n'; } cout << ans << '\n'; for(i = 0; i < n; i++) if(f[i]) cout << i << ' '; cout << '\n'; }

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

sequence.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      | ^~~~
#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...