Submission #58216

# Submission time Handle Problem Language Result Execution time Memory
58216 2018-07-17T08:09:10 Z ruhanhabib39 Ancient Books (IOI17_books) C++17
50 / 100
209 ms 103148 KB
#include <vector>
#include <cstdlib>
#include <algorithm>
#include "books.h"

long long minimum_walk(std::vector<int> p, int s) {
   if(s) return 0;
   while(p.size() && p.back() == p.size()-1) p.pop_back();

   long long res = 0;
   for(int i = 0; i < (int)p.size(); i++) {
      res += abs(p[i] - i);
   }
   int r = 0;
   for(int i = 0; i < (int)p.size()-1; i++) {
      r = std::max(r, p[i]);
      if(i == r) res += 2;
   }
   return res;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:8:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(p.size() && p.back() == p.size()-1) p.pop_back();
                      ~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 368 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 2 ms 692 KB Output is correct
12 Correct 2 ms 692 KB Output is correct
13 Correct 2 ms 692 KB Output is correct
14 Correct 2 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 3 ms 692 KB Output is correct
17 Correct 2 ms 692 KB Output is correct
18 Correct 2 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 368 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 2 ms 692 KB Output is correct
12 Correct 2 ms 692 KB Output is correct
13 Correct 2 ms 692 KB Output is correct
14 Correct 2 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 3 ms 692 KB Output is correct
17 Correct 2 ms 692 KB Output is correct
18 Correct 2 ms 692 KB Output is correct
19 Correct 3 ms 692 KB Output is correct
20 Correct 4 ms 692 KB Output is correct
21 Correct 4 ms 692 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 3 ms 692 KB Output is correct
24 Correct 2 ms 692 KB Output is correct
25 Correct 3 ms 736 KB Output is correct
26 Correct 2 ms 736 KB Output is correct
27 Correct 1 ms 764 KB Output is correct
28 Correct 3 ms 764 KB Output is correct
29 Correct 4 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 368 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 2 ms 692 KB Output is correct
12 Correct 2 ms 692 KB Output is correct
13 Correct 2 ms 692 KB Output is correct
14 Correct 2 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 3 ms 692 KB Output is correct
17 Correct 2 ms 692 KB Output is correct
18 Correct 2 ms 692 KB Output is correct
19 Correct 3 ms 692 KB Output is correct
20 Correct 4 ms 692 KB Output is correct
21 Correct 4 ms 692 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 3 ms 692 KB Output is correct
24 Correct 2 ms 692 KB Output is correct
25 Correct 3 ms 736 KB Output is correct
26 Correct 2 ms 736 KB Output is correct
27 Correct 1 ms 764 KB Output is correct
28 Correct 3 ms 764 KB Output is correct
29 Correct 4 ms 764 KB Output is correct
30 Correct 169 ms 15296 KB Output is correct
31 Correct 179 ms 22116 KB Output is correct
32 Correct 162 ms 28948 KB Output is correct
33 Correct 180 ms 35644 KB Output is correct
34 Correct 203 ms 42544 KB Output is correct
35 Correct 163 ms 49264 KB Output is correct
36 Correct 166 ms 55976 KB Output is correct
37 Correct 148 ms 62684 KB Output is correct
38 Correct 196 ms 69412 KB Output is correct
39 Correct 160 ms 76112 KB Output is correct
40 Correct 157 ms 82816 KB Output is correct
41 Correct 162 ms 89532 KB Output is correct
42 Correct 209 ms 96336 KB Output is correct
43 Correct 153 ms 103148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 103148 KB 3rd lines differ - on the 1st token, expected: '3304', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 368 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 2 ms 692 KB Output is correct
12 Correct 2 ms 692 KB Output is correct
13 Correct 2 ms 692 KB Output is correct
14 Correct 2 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 3 ms 692 KB Output is correct
17 Correct 2 ms 692 KB Output is correct
18 Correct 2 ms 692 KB Output is correct
19 Correct 3 ms 692 KB Output is correct
20 Correct 4 ms 692 KB Output is correct
21 Correct 4 ms 692 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 3 ms 692 KB Output is correct
24 Correct 2 ms 692 KB Output is correct
25 Correct 3 ms 736 KB Output is correct
26 Correct 2 ms 736 KB Output is correct
27 Correct 1 ms 764 KB Output is correct
28 Correct 3 ms 764 KB Output is correct
29 Correct 4 ms 764 KB Output is correct
30 Correct 169 ms 15296 KB Output is correct
31 Correct 179 ms 22116 KB Output is correct
32 Correct 162 ms 28948 KB Output is correct
33 Correct 180 ms 35644 KB Output is correct
34 Correct 203 ms 42544 KB Output is correct
35 Correct 163 ms 49264 KB Output is correct
36 Correct 166 ms 55976 KB Output is correct
37 Correct 148 ms 62684 KB Output is correct
38 Correct 196 ms 69412 KB Output is correct
39 Correct 160 ms 76112 KB Output is correct
40 Correct 157 ms 82816 KB Output is correct
41 Correct 162 ms 89532 KB Output is correct
42 Correct 209 ms 96336 KB Output is correct
43 Correct 153 ms 103148 KB Output is correct
44 Incorrect 2 ms 103148 KB 3rd lines differ - on the 1st token, expected: '3304', found: '0'
45 Halted 0 ms 0 KB -