| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1059924 | vjudge1 | 수열 (APIO14_sequence) | C++17 | 2081 ms | 2540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
Author:52ducbanh
The best say which I think is:Never give up _ Let me see your attemption because you deserve to get it.
*/
#include<bits/stdc++.h>
using namespace std;
using namespace chrono;
mt19937 rd(steady_clock::now().time_since_epoch().count());
#define name "task"
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define el '\n'
#define all(s) s.begin(),s.end()
#define bit(mask,i) ((mask >> i) & 1)
//For_constant//
const int MAX = 1e5 + 7;
const ll MOD = 1e9 + 7;
const ll MOD_power = 1e9 + 7;
const ll INF32 = 1e9 + 7;
const ll INF64 = 1e18;
const ll BASE = 333;
//For_initial_function//
template<typename T> T power(T a,T n) {
T res = 1;
while(n > 0)
{
if(n & 1)
{
res *= a;
res %= MOD_power;
}
a *= a;
a %= MOD_power;
n >>= 1;
}
return res;
}
template<typename T> T gcd(T a,T b) {
if(a == 0 || b == 0) return a + b;
else return gcd(b,a % b);
}
template<typename T> T lcm(T a,T b) {
return a/gcd(a,b) * b;
}
void initial(){
srand(time(NULL));
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen(name".INP","r"))
{
freopen(name".INP","r",stdin);
freopen(name".OUT","w",stdout);
}
time_t now = time(0);
cerr << ctime(&now);
}
//For_solving//
int n,k;
ll a[MAX];
ll pref[MAX];
ll ans = -1;
ll sum(int l,int r)
{
return pref[r] - pref[l - 1];
}
vector<int> tt;
vector<int> store;
int choice[MAX];
ll check()
{
ll ans1 = 0;
int bef = 1;
vector<int> be(n + 2,0);
be[0] = 1;
be[n + 1] = 1;
for(auto it : tt)
{
int l = 0;
int r = 0;
for(int i = it;i >= 0;i--)
{
if(be[i] == 1)
{
l = i + 1;
break;
}
}
for(int i = it + 1;i <= n + 1;i++)
{
if(be[i] == 1)
{
r = i - 1;
break;
}
}
ans1 += sum(l,it) * sum(it + 1,r);
be[it] = 1;
}
return ans1;
}
void Try(int j)
{
for(int i = 1;i < n;i++)
{
if(choice[i] == 0)
{
choice[i] = 1;
tt.eb(i);
if(j == k)
{
ll val = check();
if(ans < val)
{
ans = val;
store = tt;
}
}
else Try(j + 1);
choice[i] = 0;
tt.pop_back();
}
}
}
void solve()
{
cin >> n >> k;
for(int i = 1;i <= n;i++) cin >> a[i];
for(int i = 1;i <= n;i++) pref[i] = pref[i - 1] + a[i];
Try(1);
cout << ans << el;
for(auto it : store) cout << it << ' ';
}
void process_test()
{
initial();
int test;test = 1;
while(test--) solve();
}
int main()
{
//Started_time
time_point<high_resolution_clock> st,ed;
st = high_resolution_clock::now();
//Solving
process_test();
//End_time
ed = high_resolution_clock::now();
auto start = time_point_cast<milliseconds>(st).time_since_epoch().count();
auto end = time_point_cast<milliseconds>(ed).time_since_epoch().count();
cerr <<"Time_wasting(milliseconds): " << end - start << el;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
