답안 #390526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390526 2021-04-16T09:12:23 Z alireza_kaviani 고대 책들 (IOI17_books) C++11
50 / 100
161 ms 15940 KB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;

typedef long long ll;

const int MAXN = 1e6 + 10;

int n;
ll ans , ps[MAXN];

ll minimum_walk(vector<int> p, int s) {
	n = p.size();
	for(int i = 0 ; i < n ; i++){
		ps[min(p[i] , i)]++;
		ps[max(p[i] , i)]--;
	}
	partial_sum(ps , ps + MAXN , ps);
	int l = 0 , r = n;
	while(l < s && ps[l] == 0)	l++;
	while(s <= r && ps[r] == 0)	r--;
	int res = s;
	for(int i = 0 ; i < n ; i++){
		if(ps[i] == 0)	res = min(res , abs(i - s) - (i < s));
	}
	for(int i = l ; i <= r ; i++){
		ans += max(2ll , ps[i]);
	}
	return ans + res * 2;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8056 KB Output is correct
2 Correct 6 ms 8068 KB Output is correct
3 Correct 6 ms 8012 KB Output is correct
4 Correct 7 ms 8012 KB Output is correct
5 Correct 6 ms 8028 KB Output is correct
6 Correct 6 ms 8128 KB Output is correct
7 Correct 6 ms 8080 KB Output is correct
8 Correct 6 ms 8012 KB Output is correct
9 Correct 6 ms 8012 KB Output is correct
10 Correct 6 ms 8012 KB Output is correct
11 Correct 6 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 6 ms 8012 KB Output is correct
15 Correct 6 ms 8012 KB Output is correct
16 Correct 6 ms 8012 KB Output is correct
17 Correct 6 ms 8084 KB Output is correct
18 Correct 6 ms 8116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8056 KB Output is correct
2 Correct 6 ms 8068 KB Output is correct
3 Correct 6 ms 8012 KB Output is correct
4 Correct 7 ms 8012 KB Output is correct
5 Correct 6 ms 8028 KB Output is correct
6 Correct 6 ms 8128 KB Output is correct
7 Correct 6 ms 8080 KB Output is correct
8 Correct 6 ms 8012 KB Output is correct
9 Correct 6 ms 8012 KB Output is correct
10 Correct 6 ms 8012 KB Output is correct
11 Correct 6 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 6 ms 8012 KB Output is correct
15 Correct 6 ms 8012 KB Output is correct
16 Correct 6 ms 8012 KB Output is correct
17 Correct 6 ms 8084 KB Output is correct
18 Correct 6 ms 8116 KB Output is correct
19 Correct 6 ms 8016 KB Output is correct
20 Correct 6 ms 8012 KB Output is correct
21 Correct 6 ms 8012 KB Output is correct
22 Correct 6 ms 8032 KB Output is correct
23 Correct 6 ms 8012 KB Output is correct
24 Correct 6 ms 8012 KB Output is correct
25 Correct 6 ms 8012 KB Output is correct
26 Correct 6 ms 8012 KB Output is correct
27 Correct 6 ms 8012 KB Output is correct
28 Correct 6 ms 8068 KB Output is correct
29 Correct 6 ms 8012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8056 KB Output is correct
2 Correct 6 ms 8068 KB Output is correct
3 Correct 6 ms 8012 KB Output is correct
4 Correct 7 ms 8012 KB Output is correct
5 Correct 6 ms 8028 KB Output is correct
6 Correct 6 ms 8128 KB Output is correct
7 Correct 6 ms 8080 KB Output is correct
8 Correct 6 ms 8012 KB Output is correct
9 Correct 6 ms 8012 KB Output is correct
10 Correct 6 ms 8012 KB Output is correct
11 Correct 6 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 6 ms 8012 KB Output is correct
15 Correct 6 ms 8012 KB Output is correct
16 Correct 6 ms 8012 KB Output is correct
17 Correct 6 ms 8084 KB Output is correct
18 Correct 6 ms 8116 KB Output is correct
19 Correct 6 ms 8016 KB Output is correct
20 Correct 6 ms 8012 KB Output is correct
21 Correct 6 ms 8012 KB Output is correct
22 Correct 6 ms 8032 KB Output is correct
23 Correct 6 ms 8012 KB Output is correct
24 Correct 6 ms 8012 KB Output is correct
25 Correct 6 ms 8012 KB Output is correct
26 Correct 6 ms 8012 KB Output is correct
27 Correct 6 ms 8012 KB Output is correct
28 Correct 6 ms 8068 KB Output is correct
29 Correct 6 ms 8012 KB Output is correct
30 Correct 156 ms 15852 KB Output is correct
31 Correct 161 ms 15864 KB Output is correct
32 Correct 142 ms 15940 KB Output is correct
33 Correct 152 ms 15864 KB Output is correct
34 Correct 149 ms 15868 KB Output is correct
35 Correct 155 ms 15852 KB Output is correct
36 Correct 146 ms 15868 KB Output is correct
37 Correct 143 ms 15940 KB Output is correct
38 Correct 147 ms 15868 KB Output is correct
39 Correct 145 ms 15864 KB Output is correct
40 Correct 144 ms 15864 KB Output is correct
41 Correct 147 ms 15856 KB Output is correct
42 Correct 146 ms 15868 KB Output is correct
43 Correct 145 ms 15852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 8012 KB 3rd lines differ - on the 1st token, expected: '3304', found: '3594'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8056 KB Output is correct
2 Correct 6 ms 8068 KB Output is correct
3 Correct 6 ms 8012 KB Output is correct
4 Correct 7 ms 8012 KB Output is correct
5 Correct 6 ms 8028 KB Output is correct
6 Correct 6 ms 8128 KB Output is correct
7 Correct 6 ms 8080 KB Output is correct
8 Correct 6 ms 8012 KB Output is correct
9 Correct 6 ms 8012 KB Output is correct
10 Correct 6 ms 8012 KB Output is correct
11 Correct 6 ms 8012 KB Output is correct
12 Correct 6 ms 8012 KB Output is correct
13 Correct 6 ms 8012 KB Output is correct
14 Correct 6 ms 8012 KB Output is correct
15 Correct 6 ms 8012 KB Output is correct
16 Correct 6 ms 8012 KB Output is correct
17 Correct 6 ms 8084 KB Output is correct
18 Correct 6 ms 8116 KB Output is correct
19 Correct 6 ms 8016 KB Output is correct
20 Correct 6 ms 8012 KB Output is correct
21 Correct 6 ms 8012 KB Output is correct
22 Correct 6 ms 8032 KB Output is correct
23 Correct 6 ms 8012 KB Output is correct
24 Correct 6 ms 8012 KB Output is correct
25 Correct 6 ms 8012 KB Output is correct
26 Correct 6 ms 8012 KB Output is correct
27 Correct 6 ms 8012 KB Output is correct
28 Correct 6 ms 8068 KB Output is correct
29 Correct 6 ms 8012 KB Output is correct
30 Correct 156 ms 15852 KB Output is correct
31 Correct 161 ms 15864 KB Output is correct
32 Correct 142 ms 15940 KB Output is correct
33 Correct 152 ms 15864 KB Output is correct
34 Correct 149 ms 15868 KB Output is correct
35 Correct 155 ms 15852 KB Output is correct
36 Correct 146 ms 15868 KB Output is correct
37 Correct 143 ms 15940 KB Output is correct
38 Correct 147 ms 15868 KB Output is correct
39 Correct 145 ms 15864 KB Output is correct
40 Correct 144 ms 15864 KB Output is correct
41 Correct 147 ms 15856 KB Output is correct
42 Correct 146 ms 15868 KB Output is correct
43 Correct 145 ms 15852 KB Output is correct
44 Incorrect 6 ms 8012 KB 3rd lines differ - on the 1st token, expected: '3304', found: '3594'
45 Halted 0 ms 0 KB -