답안 #832263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832263 2023-08-21T08:07:03 Z MadokaMagicaFan 고대 책들 (IOI17_books) C++14
0 / 100
1 ms 300 KB
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define sz(v) ((int)v.size())

ll minimum_walk(vector<int> p, int s) {
	/* assumes s = 0 */
	ll ans = 0;
	int n = sz(p);
	for (int i = 0; i < n; ++i)
		if (p[i] != i) {
			ans += i;
			break;
		}

	for (int i = n-1; i >= 0; --i)
		if (p[i] != i) {
			ans += i;
			break;
		}

	for (int i = 0; i < n; ++i)
		if (p[i] < i)
			ans += (ll)(i - p[i]);

	return ans;
}


#ifdef ONPC
int main() {
	int n, s;
	cin >> n >> s;
	vector<int> p(n);
	for(int i = 0; i < n; ++i)
		cin >> p[i];

	cout << minimum_walk(p, s);
}
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '7'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '7'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '7'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 300 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2371'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '8', found: '7'
4 Halted 0 ms 0 KB -