답안 #1075925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075925 2024-08-26T09:49:25 Z amin 고대 책들 (IOI17_books) C++14
0 / 100
1 ms 348 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long minimum_walk(vector<int> p, int s) {
	ll ans=0;
	ll n=p.size();
	ll ma=0;
	ll mi=0;
	int o[n];
	for(int i=0;i<n;i++)
    {
        o[p[i]]=i;
    }
	for(int i=0;i<n;i++)
    {
        if(p[i]==i)
        {
            continue;
        }
        if(p[i]>i)
        {
           if(mi==-1)
            mi=i;
        ma=i;
        }


            ans+=abs(p[i]-i);
    }
    return ans+2*mi;
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:8:5: warning: variable 'ma' set but not used [-Wunused-but-set-variable]
    8 |  ll ma=0;
      |     ^~
books.cpp:10:6: warning: variable 'o' set but not used [-Wunused-but-set-variable]
   10 |  int o[n];
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 3rd lines differ - on the 1st token, expected: '6', found: '4'
2 Halted 0 ms 0 KB -