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

Submission #3894200

Source Code Expand

Copy
```#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
static ll L,N;
static ll X[200010];
scanf("%lld%lld",&L,&N);
for(int i = 1 ; i <= N ; i ++){
scanf("%d",&X[i]);
}

ll ret = 0;
ll ans = X[N];
ll l = 0;
while(1){
ret = max( ret , ans );
if(2*(l+1) >= N)break;
ans -= X[N-l]+X[N-(l+1)];
ans += 2*(X[N-(2*l+1)]+X[N-(2*l+2)]);
ans += 2*(L-X[N-l]);
ret = max ( ret , ans+X[N-(l+1)]-(L-X[N-l])-2*X[N-(2*l+2)] );
l ++;
}
for(int i = 1 ; i <= N ; i ++){
X[i] = L-X[i];
}
reverse(X+1,X+N+1);
ans = X[N];
l = 0;
while(1){
ret = max( ret , ans );
if(2*(l+1) >= N)break;
ans -= X[N-l]+X[N-(l+1)];
ans += 2*(X[N-(2*l+1)]+X[N-(2*l+2)]);
ans += 2*(L-X[N-l]);
ret = max ( ret , ans+X[N-(l+1)]-(L-X[N-l])-2*X[N-(2*l+2)] );
l ++;
}
if(N%2 == 0){
ans = 0;
for(int i = 1 ; i <= N/2 ; i ++){
ans += X[i];
}
for(int i = N/2+1 ; i <= N ; i ++){
ans += L-X[i];
}
ans -= min( X[N/2] , L-X[N/2+1] );
ret = max ( ret , ans );
}
cout << ret << endl;
}

```

#### Submission Info

Submission Time 2018-12-29 21:33:52+0900 B - Tree Burning yokozuna57 C++14 (GCC 5.4.1) 0 2016 Byte WA 27 ms 1792 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:42:19: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll* {aka long long int*}’ [-Wformat=]
scanf("%d",&X[i]);
^
./Main.cpp:40:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&L,&N);
^
./Main.cpp:42:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&X[i]);
^
```

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
Subtask1 0 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 39.txt, 40.txt, s1.txt, s2.txt, s3.txt
All 0 / 500 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 2 ms 256 KB
02.txt 2 ms 256 KB
03.txt 2 ms 256 KB
04.txt 2 ms 256 KB
05.txt 2 ms 256 KB
06.txt 2 ms 256 KB
07.txt 2 ms 256 KB
08.txt 2 ms 256 KB
09.txt 2 ms 256 KB
10.txt 2 ms 256 KB
11.txt 2 ms 256 KB
12.txt 2 ms 256 KB
13.txt 2 ms 256 KB
14.txt 2 ms 256 KB
15.txt 2 ms 256 KB
16.txt 2 ms 256 KB
17.txt 2 ms 256 KB
18.txt 2 ms 256 KB
19.txt 2 ms 256 KB
20.txt 2 ms 256 KB
21.txt 2 ms 256 KB
22.txt 2 ms 256 KB
23.txt 2 ms 256 KB
24.txt 2 ms 256 KB
25.txt 26 ms 1792 KB
26.txt 26 ms 1792 KB
27.txt 26 ms 1792 KB
28.txt 27 ms 1792 KB
29.txt 26 ms 1792 KB
30.txt 26 ms 1792 KB
31.txt 26 ms 1792 KB
32.txt 26 ms 1792 KB
33.txt 26 ms 1792 KB
34.txt 24 ms 1792 KB
35.txt 26 ms 1792 KB
36.txt 26 ms 1792 KB
37.txt 26 ms 1792 KB
38.txt 23 ms 1792 KB
39.txt 1 ms 256 KB
40.txt 1 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB