Submission #289275

#TimeUsernameProblemLanguageResultExecution timeMemory
289275TouubsAncient Books (IOI17_books)C++17
50 / 100
174 ms9080 KiB
#include "books.h" #include <bits/stdc++.h> long long minimum_walk(std::vector<int> p, int s) { std::vector<bool> visited(p.size()); long long res = 0; int maxVis = 0; for (int i = 0; i < p.size(); i++) { if (maxVis < i) res+=2; res += abs(p[i] - i); maxVis = std::max(maxVis, p[i]); } for (int i = p.size() - 1; i > 0 && p[i] == i; i--) res-=2; return res; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:8:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 0; i < p.size(); i++) {
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...