Submission #428053

#TimeUsernameProblemLanguageResultExecution timeMemory
428053inwbearAncient Books (IOI17_books)C++14
50 / 100
169 ms14844 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; set<pair<int,int> >ss; long long ans=0; long long minimum_walk(std::vector<int> p, int s) { int ed=0,rr=0,sw=0; for(int i=0;i<p.size();i++) { if(p[i]!=i)sw=max(sw,max(i,p[i])); } for(int i=0;i<p.size();i++) { ed=max(ed,p[i]); if(sw==i)ans+=(rr)*2; if(ed==i) { rr++; } ans+=abs(i-p[i]); } return ans; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<p.size();i++)
      |                 ~^~~~~~~~~
books.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     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...