Submission #286874

# Submission time Handle Problem Language Result Execution time Memory
286874 2020-08-31T06:07:43 Z tmwilliamlin168 Ancient Books (IOI17_books) C++14
0 / 100
1 ms 384 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll minimum_walk(vector<int> p, int s) {
	int n=p.size();
	ll ans=0;
	vector<int> a(n);
	for(int i=0; i<n; ++i) {
		ans+=abs(i-p[i]);
		++a[min(i, p[i])];
		--a[max(i, p[i])];
	}
	for(int i=0; i+1<n; ++i) {
		a[i+1]+=a[i];
		ans+=2*!a[i];
	}
	for(int i=n-2; ~i&&!a[i]; ++i)
		ans-=2*!a[i];
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '4', found: '-2'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '4', found: '-2'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '4', found: '-2'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB 3rd lines differ - on the 1st token, expected: '4', found: '-2'
6 Halted 0 ms 0 KB -