답안 #412940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
412940 2021-05-27T20:27:50 Z Pichon5 고대 책들 (IOI17_books) C++17
0 / 100
1 ms 288 KB
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vi vector<int>
using namespace std;


ll minimum_walk(vector<int> p,int s){
   ll res=0;
   int n=p.size();
   vi cant(n+2,0);
   for(int i=0;i<n;i++){
      if(p[i]==i)continue;
      res+=abs(i-p[i]);
      int mi=(i,p[i]);
      int ma=(i,p[i]);
      cant[mi]++;
      cant[ma+1]--;
   }  
   int sum=0;
   int acum=0;
   for(int i=0;i<n;i++){
      acum+=cant[i];
      if(acum==0){
         sum++;
      }else{
         res+=2*sum;
         sum=0;        
      }
   }
   return res;    
   
}

Compilation message

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:15:15: warning: left operand of comma operator has no effect [-Wunused-value]
   15 |       int mi=(i,p[i]);
      |               ^
books.cpp:16:15: warning: left operand of comma operator has no effect [-Wunused-value]
   16 |       int ma=(i,p[i]);
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 288 KB 3rd lines differ - on the 1st token, expected: '3304', found: '3824'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -