Submission #364615

# Submission time Handle Problem Language Result Execution time Memory
364615 2021-02-09T14:47:16 Z rqi Ancient Books (IOI17_books) C++14
0 / 100
1 ms 364 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef long long ll;

#define sz(x) (int)(x).size()

long long minimum_walk(vi p, int s) {
	int n = sz(p);
	vi cover = vi(n, 0);
	vi dirover = vi(n, 0); //right = +1
	ll ans = 0;
	for(int i = 0; i < n; i++){
		cover[min(i, p[i])]++;
		cover[max(i, p[i])]--;
		dirover[i]++;
		dirover[p[i]]--;
		ans+=abs(p[i]-i);
	}

	//cout << ans << "\n";

	for(int i = 1; i < n; i++){
		cover[i]+=cover[i-1];
		dirover[i]+=dirover[i-1];
	}

	

	for(int i = 0; i < n; i++){
		ans+=abs(dirover[i]);
	}

	for(int i = 0; i < n-1; i++){
		if(cover[i] == 0){
			ans+=2;
		}
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB 3rd lines differ - on the 1st token, expected: '4', found: '6'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB 3rd lines differ - on the 1st token, expected: '4', found: '6'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB 3rd lines differ - on the 1st token, expected: '4', found: '6'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 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 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB 3rd lines differ - on the 1st token, expected: '4', found: '6'
6 Halted 0 ms 0 KB -