답안 #593608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
593608 2022-07-11T12:30:51 Z yutabi 고대 책들 (IOI17_books) C++14
50 / 100
126 ms 15068 KB
#include "books.h"


#include <bits/stdc++.h>
using namespace std;


#define pb push_back


typedef long long ll;


long long minimum_walk(std::vector<int> p, int s)
{
	while(p.size() && p.back()+1==p.size())
	{
		p.pop_back();
	}

	ll ans=0;

	int mex=0;

	vector <bool> v(1000007,0);

	for(int i=0;i<p.size();i++)
	{
		ans+=abs(i-p[i]);

		v[p[i]]=1;

		while(v[mex]==1)
		{
			mex++;
		}

		if(i+1!=p.size() && mex>i)
		{
			ans+=2;
		}
	}




	
	return ans;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:16:30: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  while(p.size() && p.back()+1==p.size())
      |                    ~~~~~~~~~~^~~~~~~~~~
books.cpp:27:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i=0;i<p.size();i++)
      |              ~^~~~~~~~~
books.cpp:38:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   if(i+1!=p.size() && mex>i)
      |      ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 432 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 432 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 432 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 424 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 440 KB Output is correct
27 Correct 1 ms 436 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 432 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 432 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 424 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 440 KB Output is correct
27 Correct 1 ms 436 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 94 ms 14952 KB Output is correct
31 Correct 91 ms 14948 KB Output is correct
32 Correct 109 ms 14948 KB Output is correct
33 Correct 99 ms 14948 KB Output is correct
34 Correct 95 ms 14948 KB Output is correct
35 Correct 126 ms 14960 KB Output is correct
36 Correct 103 ms 14988 KB Output is correct
37 Correct 94 ms 14960 KB Output is correct
38 Correct 91 ms 14944 KB Output is correct
39 Correct 93 ms 15068 KB Output is correct
40 Correct 110 ms 14952 KB Output is correct
41 Correct 92 ms 14944 KB Output is correct
42 Correct 87 ms 14952 KB Output is correct
43 Correct 87 ms 14924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 432 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 432 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 0 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 432 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 424 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 440 KB Output is correct
27 Correct 1 ms 436 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 94 ms 14952 KB Output is correct
31 Correct 91 ms 14948 KB Output is correct
32 Correct 109 ms 14948 KB Output is correct
33 Correct 99 ms 14948 KB Output is correct
34 Correct 95 ms 14948 KB Output is correct
35 Correct 126 ms 14960 KB Output is correct
36 Correct 103 ms 14988 KB Output is correct
37 Correct 94 ms 14960 KB Output is correct
38 Correct 91 ms 14944 KB Output is correct
39 Correct 93 ms 15068 KB Output is correct
40 Correct 110 ms 14952 KB Output is correct
41 Correct 92 ms 14944 KB Output is correct
42 Correct 87 ms 14952 KB Output is correct
43 Correct 87 ms 14924 KB Output is correct
44 Incorrect 1 ms 432 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
45 Halted 0 ms 0 KB -