제출 #780944

#제출 시각아이디문제언어결과실행 시간메모리
780944teokakabadze수열 (APIO14_sequence)C++17
0 / 100
49 ms3780 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; p[i] = t + a[i]; t += a[i]; } t = 0; for(i = n - 1; i >= 0; i--) { s[i] = t + a[i]; t += a[i]; 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...