제출 #135203

#제출 시각아이디문제언어결과실행 시간메모리
135203anayk고대 책들 (IOI17_books)C++14
0 / 100
2 ms376 KiB
#include <iostream> #include "books.h" int min, max; int l, r; int n; void add(int val) { min = std::min(min, val); max = std::max(max, val); } long long minimum_walk(std::vector<int> p, int s) { n = p.size(); long long answer = 0; for(int i = 0; i < p.size(); i++) answer += (long long) abs(i-p[i]); min = max = l = r = s; add(p[s]); while(min > 0 || max < n-1) { if(l > min) { l--; add(p[l]); } else if(r < max) { r++; add(p[r]); } else { answer += 2; if(max < n-1) max++; else min--; } } return answer; }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:20:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  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...