Contest Duration: ~ (local time) (140 minutes) Back to Home

Submission #3214432

Source Code Expand

Copy
```#include <bits/stdc++.h>

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;

long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
cin.tie(0);
ios::sync_with_stdio(false);

cin>>n>>x;
rep(i,n)cin>>a[i];
if(n==1){
ans+=a[0];
ans+=x;
ans+=pow(2,2)*a[0];
ans+=x;
Cout(ans);
return 0;
}
ans=n*x;
ll cntt=0,anss=LINF;
for(ll i=1;2*i<=n;i++){
pos=5;
cntt=0;
rrrep(j,n-1,0){
cnt+=a[j]*pos;
cntt++;
if(cntt==2*i){
fl=true;
cntt=0;
pos+=2;
}
if(fl&&cntt==i){
cntt=0;
pos+=2;
}
}

//Cout(cnt);
cnt+=x*i;
anss=min(anss,cnt);
//cout<<cnt<<" "<<i<<" "<<anss<<"\n";
//Cout(cnt);
cnt=0;
fl=false;
}
Cout(ans+anss);

return 0;
}
```

#### Submission Info

Submission Time 2018-09-17 13:32:25+0900 B - Garbage Collector asdf1 C++ (GCC 5.4.1) 0 2168 Byte WA 2103 ms 1792 KB

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 0 / 400 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, stest_01.txt, stest_02.txt, stest_03.txt, stest_04.txt, stest_05.txt, stest_06.txt, stest_07.txt, stest_08.txt, stest_09.txt, stest_10.txt, stest_11.txt, stest_12.txt
All 0 / 300 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, stest_01.txt, stest_02.txt, stest_03.txt, stest_04.txt, stest_05.txt, stest_06.txt, stest_07.txt, stest_08.txt, stest_09.txt, stest_10.txt, stest_11.txt, stest_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 1 ms 256 KB
stest_01.txt 4 ms 256 KB
stest_02.txt 4 ms 256 KB
stest_03.txt 1 ms 256 KB
stest_04.txt 1 ms 256 KB
stest_05.txt 3 ms 256 KB
stest_06.txt 2 ms 256 KB
stest_07.txt 4 ms 256 KB
stest_08.txt 4 ms 256 KB
stest_09.txt 1 ms 256 KB
stest_10.txt 4 ms 256 KB
stest_11.txt 4 ms 256 KB
stest_12.txt 1 ms 256 KB
test_13.txt 2103 ms 1792 KB
test_14.txt 2103 ms 1792 KB
test_15.txt 893 ms 512 KB
test_16.txt 2103 ms 1792 KB
test_17.txt 2103 ms 1792 KB
test_18.txt 514 ms 512 KB
test_19.txt 2103 ms 1792 KB
test_20.txt 2103 ms 1792 KB
test_21.txt 2103 ms 1792 KB
test_22.txt 2103 ms 1792 KB
test_23.txt 2103 ms 1792 KB
test_24.txt 2103 ms 1792 KB
test_25.txt 2103 ms 1024 KB
test_26.txt 2103 ms 1792 KB
test_27.txt 2103 ms 1792 KB
test_28.txt 2103 ms 1536 KB