제출 #498413

#제출 시각아이디문제언어결과실행 시간메모리
498413Nalrimet수열 (APIO14_sequence)C++17
11 / 100
2078 ms9676 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define ppb pop_back long long n, k, answ = -1e18, sum, pref[100005], a[100005]; vector<int> v, ans; void rec(int pos, int last){ if(pos == n){ if(sum > answ){ answ = sum; ans = v; } return; } if(v.size() != k){ v.pb(pos); sum += (pref[n] - pref[pos]) * (pref[pos] - pref[last]); rec(pos + 1, pos); sum -= (pref[n] - pref[pos]) * (pref[pos] - pref[last]); v.ppb(); } rec(pos + 1, last); } main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for(int i = 1; i <= n; ++i){ cin >> a[i]; pref[i] = pref[i - 1] + a[i]; } rec(1, 0); cout << answ << '\n'; for(auto to : ans){ cout << to << ' '; } return 0; }

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

sequence.cpp: In function 'void rec(long long int, long long int)':
sequence.cpp:19:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   19 |     if(v.size() != k){
      |        ~~~~~~~~~^~~~
sequence.cpp: At global scope:
sequence.cpp:29:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 |  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...