QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#174506 | #6632. Minimize Median | PERAPRO# | Compile Error | / | / | C++20 | 2.9kb | 2023-09-10 08:31:31 | 2023-09-10 08:31:32 |
Judging History
answer
/// Write by Daniel Perez .PERAPRO
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(), s.end()
#define mp make_pair
#define int long long
#define ll long long
// typedef unsigned long long ull;
typedef long double ld;
using vi=vector<int>;
using vl=vector<ll>;
using pii=pair<int,int>;
#define endl '\n'
char el = '\n';
char esp = ' ';
int cost [1000001] ;
int cont [1000001] ;
int ans [1000001] ;
bool visit [1000001] ;
int n , m , c ;
bool bus ( int h ){
int sum1 = 0 ;
for ( int i = 0 ; i <= m ; i++ ) visit [i] = 0 ;
int cont1 = 0 ;
priority_queue < pair < int , int > > q ;
for ( int i = 0 ; i <= h ; i++ ){
q.push ( { 0 , i } ) ;
}
while ( !q.empty( ) ){
pair < int , int > k = q.top ( ) ;
q.pop ( ) ;
if ( visit [k.second] ) continue ;
visit [k.second] = true ;
ans[k.second] = -k.first ;
for ( int i = 0 ; i < cont[k.second] ; i++ ){
sum1 += ans[k.second] ;
cont1++ ;
if ( sum1 > c ) return false;
if ( cont1 == n / 2 + 1 ) return true ;
}
for ( int i = 1 ; i <= m ; i++ ){
int p = k.second * i ;
int sum = - ( (- ( k.first)) + cost[i] ) ;
if ( p > m ) break ;
for ( int d = 0 ; d < i ; d++ ){
if ( p + d > m ) break ;
q.push ( {sum , p + d }) ;
}
}
}
return false ;
}
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &v){
for(auto const &i: v){
os<<i<<" ";
}
os<<'\n';
return os;
}
string yes="YES";
string no="NO";
int32_t main(){
fast_io;
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/
int tc;
cin>>tc;
while(tc--){
cin>>n>>m>>c ;
for ( int i = 0 ; i <= m ; i++ ) cont [i] = 0 ;
for ( int i = 0 ; i < n ; i++ ){
int a ;
cin>>a ;
cont[a]++ ;
}
for ( int i = 1 ;i <= m ;i++){
int a ;
cin>>a ;
cost[i] = a ;
}
int lo = 0 ;
int hi = m+1 ;
int best = INT_MAX ;
while ( lo < hi ){
int mid = ( lo + hi ) / 2 ;
if ( bus ( mid ) ){
best = min ( best , mid ) ;
hi = mid ;
}
else{
lo = mid + 1 ;
}
}
cout<<best<<endl ;
}
}
/*
*/
Details
answer.code: In function ‘bool bus(long long int)’: answer.code:30:38: error: reference to ‘visit’ is ambiguous 30 | for ( int i = 0 ; i <= m ; i++ ) visit [i] = 0 ; | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:133, from answer.code:2: /usr/include/c++/11/variant:1774:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’ 1774 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ /usr/include/c++/11/variant:1734:5: note: ‘template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)’ 1734 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ answer.code:26:6: note: ‘bool visit [1000001]’ 26 | bool visit [1000001] ; | ^~~~~ answer.code:39:14: error: reference to ‘visit’ is ambiguous 39 | if ( visit [k.second] ) continue ; | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:133, from answer.code:2: /usr/include/c++/11/variant:1774:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’ 1774 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ /usr/include/c++/11/variant:1734:5: note: ‘template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)’ 1734 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ answer.code:26:6: note: ‘bool visit [1000001]’ 26 | bool visit [1000001] ; | ^~~~~ answer.code:40:9: error: reference to ‘visit’ is ambiguous 40 | visit [k.second] = true ; | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:133, from answer.code:2: /usr/include/c++/11/variant:1774:5: note: candidates are: ‘template<class _Res, class _Visitor, class ... _Variants> constexpr _Res std::visit(_Visitor&&, _Variants&& ...)’ 1774 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ /usr/include/c++/11/variant:1734:5: note: ‘template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)’ 1734 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ answer.code:26:6: note: ‘bool visit [1000001]’ 26 | bool visit [1000001] ; | ^~~~~