Submission #1052295

#TimeUsernameProblemLanguageResultExecution timeMemory
10522950npataAncient Books (IOI17_books)C++17
0 / 100
0 ms348 KiB
#include "books.h" #include<bits/stdc++.h> using namespace std; #define int long long #define vec vector long long minimum_walk(std::vector<int32_t> P, int32_t S) { int ans = 0; int N = P.size(); for(int i = 0; i<N; i++) { ans += abs(P[i]-i); } int r = P[0]; int lst = 0; for(int i = 0; i<N; i++) { if(P[i] != i) lst = i; } for(int i = 1; i<N; i++) { if(r < i) ans += 2; r = max((int) P[i], r); } return ans; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int32_t)':
books.cpp:15:6: warning: variable 'lst' set but not used [-Wunused-but-set-variable]
   15 |  int lst = 0;
      |      ^~~
#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...