답안 #1075921

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075921 2024-08-26T09:48:41 Z amin 고대 책들 (IOI17_books) C++14
0 / 100
1 ms 436 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=-1;
	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 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 344 KB 3rd lines differ - on the 1st token, expected: '0', found: '-2'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 344 KB 3rd lines differ - on the 1st token, expected: '0', found: '-2'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 344 KB 3rd lines differ - on the 1st token, expected: '0', found: '-2'
10 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 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 0 ms 344 KB 3rd lines differ - on the 1st token, expected: '0', found: '-2'
10 Halted 0 ms 0 KB -