Submission #1075931

#TimeUsernameProblemLanguageResultExecution timeMemory
1075931aminAncient Books (IOI17_books)C++14
12 / 100
1 ms600 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; #define ll long long long long minimum_walk(vector<int> p, int s) { ll ans=0; ll n=p.size(); ll ma=0; ll mi=-1; int o[n]; for(int i=0;i<n;i++) { o[p[i]]=i; } for(int i=0;i<n;i++) { if(p[i]==i) { continue; } if(p[i]>i) { if(mi==-1) mi=i; ma=i; } ans+=abs(p[i]-i); } if(mi==-1) mi=0; return ans+2*mi; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:8:5: warning: variable 'ma' set but not used [-Wunused-but-set-variable]
    8 |  ll ma=0;
      |     ^~
books.cpp:10:6: warning: variable 'o' set but not used [-Wunused-but-set-variable]
   10 |  int o[n];
      |      ^
#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...