답안 #72690

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72690 2018-08-26T15:21:20 Z mhnd 고대 책들 (IOI17_books) C++14
0 / 100
3 ms 496 KB
#include "books.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5+50;
const int oo = 1e9;
const int mod = 1e9+7;

ll minimum_walk(vector<int> p, int s) {
	ll ans = 0;
	int mx=-1;
	for(int i=0;i<p.size();i++){
		ans += abs(i-p[i]);
		mx = max(mx,p[i]);
		if(mx==i)ans+=2;
	}
	for(int i=0;i<s;i++){
		if(p[i]!=i)continue;
		ans-=2;
	}
	for(int i=p.size()-1;i>s;i--){
		if(p[i]!=i)continue;
		ans-=2;
	}
	return ans - 2;
}

Compilation message

books.cpp: In function 'll minimum_walk(std::vector<int>, int)':
books.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<p.size();i++){
              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 496 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 496 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 496 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 496 KB 3rd lines differ - on the 1st token, expected: '3304', found: '1664'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 496 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
3 Halted 0 ms 0 KB -