Submission #1149776

#TimeUsernameProblemLanguageResultExecution timeMemory
1149776notasingle...Split the sequence (APIO14_sequence)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; long long n, k, p; long long lst[200005], slot[200005][201], trace[200005][201]; deque<pair<long long, long long>> D; inline f(pair<long long, long long> P, long long t){ return P.first + (lst[t] - lst[P.second])*(lst[t] - lst[P.second]); } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; p = n; for(long long i = 1; i <= n; ++i){ cin >> lst[i]; lst[i] += lst[i-1]; slot[i][0] = lst[i] * lst[i]; } for(long long _ = 1; _ <= k; ++_){ D.push_front({slot[_][_-1], _}); for(long long i = _ + 1; i <= n; ++i){ while(D.size() > 1 && f(D.front(), i) > f(D[1], i)) D.pop_front(); D.push_back({slot[i][_-1], i}); slot[i][_] = f(D.front(), i); trace[i][_] = D.front().second; } while(!D.empty()) D.pop_front(); } cout << (lst[n] * lst[n] - slot[n][k]) / 2 << '\n'; while(k--){ p = trace[p][k+1]; cout << p << ' '; } }

Compilation message (stderr)

sequence.cpp:6:8: error: ISO C++ forbids declaration of 'f' with no type [-fpermissive]
    6 | inline f(pair<long long, long long> P, long long t){
      |        ^