제출 #942998

#제출 시각아이디문제언어결과실행 시간메모리
942998kokoxuyaA Difficult(y) Choice (BOI21_books)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define int long long //#include <iostream> //#include <algorithm> int currsum; bool checkers(int x, int K, vector<pair<int,int>> &ans, int A) //return false if adding would make it too large //return true if not and insert x into the vector //ans : {index, value} pair { int ants; int temp1 = skim(x); int cantake = (2 * A) - currsum; if ((currsum + (temp1 - ans[K].second)) > (2 * A)) { return false; } else { int hi = K, lo = 1, mid; while (hi > lo) { //printf("stuck in checkers\n"); mid = (hi + lo)/2; if (((temp1 - ans[mid].second) <= cantake)) //won't exceed : go lower { //printf("replacing %d is ok\n",mid); hi = mid; } else { lo = mid + 1; } } currsum += (temp1 - ans[lo].second); //cout << "x : " << x << "\n"; ans[lo] = {x,temp1}; //printf("replaced %d", lo); } //printf ("this is currsum now : %d",currsum); sort(ans.begin() + 1, ans.end()); return true; } void solve(int N, int K, long long A, int S) { vector<pair<int,int>>ans(K + 1); int temp1,temp2; for (int a = 1; a <= K; a++) { temp2 = skim(a); ans[a] = {a,temp2}; currsum += temp2; } if (currsum > (2 * A)) { impossible(); } vector<int>kokonut; if ((currsum >= A) && (currsum <= (2 * A))) { for (int a = 1; a <= K; a++) { kokonut.push_back(ans[a].first); } answer(kokonut); } int hi = N,lo = K + 1,mid; int anss; while (hi >= lo) { //printf("stuck in solve\n"); mid = (hi + lo)/2; if (checkers(mid, K, ans, A)) //keyi { anss = mid; lo = mid + 1; } else { hi = mid - 1; } //printf("\n%d is between %d and %d", currsum, A, (2 * A)); if ((currsum >= A) && (currsum <= (2 * A))) { for (int a = 1; a <= K; a++) { kokonut.push_back(ans[a].first); } answer(kokonut); } } //printf("is this one\n"); impossible(); }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'bool checkers(long long int, long long int, std::vector<std::pair<long long int, long long int> >&, long long int)':
books.cpp:16:9: warning: unused variable 'ants' [-Wunused-variable]
   16 |     int ants;
      |         ^~~~
books.cpp: In function 'void solve(long long int, long long int, long long int, long long int)':
books.cpp:75:16: error: could not convert 'kokonut' from 'vector<long long int>' to 'vector<int>'
   75 |         answer(kokonut);
      |                ^~~~~~~
      |                |
      |                vector<long long int>
books.cpp:102:20: error: could not convert 'kokonut' from 'vector<long long int>' to 'vector<int>'
  102 |             answer(kokonut);
      |                    ^~~~~~~
      |                    |
      |                    vector<long long int>
books.cpp:55:9: warning: unused variable 'temp1' [-Wunused-variable]
   55 |     int temp1,temp2;
      |         ^~~~~