Submission #420292

#TimeUsernameProblemLanguageResultExecution timeMemory
420292Andyvanh1Ancient Books (IOI17_books)C++14
50 / 100
164 ms14936 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define vt vector #define INF 0x3f3f3f3f #define pb push_back #define all(x) (x).begin(),(x).end() #define rep(i,x) for(int (i) = 0;(i) < (x); (i)++) #define MOD 1000000007 typedef vt<int> vi; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; ll minimum_walk(vi p, int s){ for(int i = p.size()-1; i>=0; i--){ if(p[i]==i)p.pop_back(); else break; } ll ans = 0; int curlast = 0; int n = p.size(); rep(i,n)ans+=1ll*(abs(p[i]-i)); for(int i = 0; i < n; i++){ if(i>curlast)ans+=2; curlast = max(curlast,p[i]); } return ans; }

Compilation message (stderr)

books.cpp: In function 'll minimum_walk(vi, int)':
books.cpp:10:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rep(i,x) for(int (i) = 0;(i) < (x); (i)++)
      |                          ^
books.cpp:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,n)ans+=1ll*(abs(p[i]-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...