QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#671722 | #5417. Chat Program | _Dusker | Compile Error | / | / | C++20 | 2.7kb | 2024-10-24 14:11:48 | 2024-10-24 14:11:49 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int MAX=2e5+5;
int n,k,m,c,d;
int a[MAX],tmp[MAX];
int ori[MAX],tot_ori;
set<int> s;
int g[MAX],tot;
int sum[MAX*4];
int findf(int x){
return s.lower_bound(x) - s.begin();
/*int l=1,r=tot,res=-1;
while(l<=r){
int mid=l+r>>1;
if(g[mid]>=x){
res=mid;
r=mid-1;
}
else
l=mid+1;
}
return res;*/
}
void modify(int k,int l,int r,int p,int v){
if(r<p||l>p)
return;
if(l==r&&l==p){
sum[k]+=v;
return;
}
int mid=l+r>>1;
modify(k<<1,l,mid,p,v);
modify(k<<1|1,mid+1,r,p,v);
sum[k]=sum[k<<1]+sum[k<<1|1];
}
int query(int k,int l,int r,int x,int y){
if(y<l||x>r)
return 0;
if(l>=x&&r<=y)
return sum[k];
int mid=l+r>>1;
int res=0;
res=query(k<<1,l,mid,x,y);
res+=query(k<<1|1,mid+1,r,x,y);
return res;
}
bool check(int x){
memset(sum,0,sizeof(sum));
int res=0;
tot_ori=0;
for(int i=1;i<=n;++i){
if(a[i]>=x)
tot_ori++;
}
ori[1]=0;
for(int i=1;i<=m;++i){
if(a[i]>=x)
ori[1]++;
}
for(int i=2;i+m-1<=n;++i){
ori[i]=ori[i-1];
if(a[i-1]>=x)
ori[i]--;
if(a[i+m-1]>=x)
ori[i]++;
// cout<<"(("<<i<<" "<<ori[i]<<endl;
}
// cout<<tot_ori<<endl;
x-=c;
for(int i=n-m+1;i<=n;++i){
int p=findf(tmp[i]);
modify(1,1,tot,p,1);
}
int p=findf(x);
if(p!=-1)
res=max(res,query(1,1,tot,p,tot)+tot_ori-ori[n-m+1]);
for(int i=n-m;i>=1;--i){
x-=d;
int p=findf(tmp[i+m]);
modify(1,1,tot,p,-1);
p=findf(tmp[i]);
// cout<<"&"<<g[p]<<endl;
modify(1,1,tot,p,1);
p=findf(x);
// cout<<"@"<<g[p]<<endl;
if(p!=-1)
res=max(res,query(1,1,tot,p,tot)+tot_ori-ori[i]);
// cout<<i<<" * "<<query(1,1,tot,p,tot)+tot_ori-ori[i]<<" "<<ori[i]<<endl;
}
// cout<<res<<"*"<<endl;
return res>=k;
}
int read(){
int x = 0, f = 1;
char c = getchar();
while(c < '0' || c > '9'){
if(c == '-'){
f = -1;
}
c = getchar();
}
while(c >= '0' && c <= '9'){
x = x*10+c-'0';
c = getchar();
}
return x*f;
}
signed main(){
// freopen("data.in","r",stdin);
// freopen("data.out","w",stdout);
cin>>n>>k>>m>>c>>d;
for(int i=1;i<=n;++i)
a[i]=read();
for(int i=1;i<=n;++i)
tmp[i]=a[i];
int cur=0;
for(int i=1;i<=m;++i){
tmp[n-m+i]+=cur;
cur+=d;
}
cur=0;
for(int i=n-m+1;i>=1;--i){
tmp[i]+=cur;
cur-=d;
}
for(int i=1;i<=n;++i){
s.insert(tmp[i]);
}
//for(set<int>::iterator i=s.begin();i!=s.end();++i)
//g[++tot]=*i;
int l=0,r=2e15,res;
// check(9);
while(l<=r){
int mid=l+r>>1;
// cout<<mid<<endl;
if(check(mid)){
res=mid;
l=mid+1;
}
else
r=mid-1;
}
cout<<res;
return 0;
}
Details
answer.code: In function ‘long long int findf(long long int)’: answer.code:13:33: error: no match for ‘operator-’ (operand types are ‘std::set<long long int>::iterator’ {aka ‘std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator’} and ‘std::set<long long int>::iterator’ {aka ‘std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator’}) 13 | return s.lower_bound(x) - s.begin(); | ~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~ | | | | | _Rb_tree_const_iterator<[...]> | _Rb_tree_const_iterator<[...]> In file included from /usr/include/c++/13/bits/stl_algobase.h:67, from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_iterator.h:625:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_IteratorL>&, const reverse_iterator<_IteratorR>&)’ 625 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:625:5: note: template argument deduction/substitution failed: answer.code:13:43: note: ‘std::set<long long int>::iterator’ {aka ‘std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator’} is not derived from ‘const std::reverse_iterator<_IteratorL>’ 13 | return s.lower_bound(x) - s.begin(); | ^ /usr/include/c++/13/bits/stl_iterator.h:1800:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’ 1800 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1800:5: note: template argument deduction/substitution failed: answer.code:13:43: note: ‘std::set<long long int>::iterator’ {aka ‘std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator’} is not derived from ‘const std::move_iterator<_IteratorL>’ 13 | return s.lower_bound(x) - s.begin(); | ^ In file included from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127: /usr/include/c++/13/complex:365:5: note: candidate: ‘template<class _Tp> constexpr std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)’ 365 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/13/complex:365:5: note: template argument deduction/substitution failed: answer.code:13:43: note: ‘std::set<long long int>::iterator’ {aka ‘std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator’} is not derived from ‘const std::complex<_Tp>’ 13 | return s.lower_bound(x) - s.begin(); | ^ /usr/include/c++/13/complex:374:5: note: candidate: ‘template<class _Tp> constexpr std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)’ 374 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/13/complex:374:5: note: template argument deduction/substitution failed: answer.code:13:43: note: ‘std::set<long long int>::iterator’ {aka ‘std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator’} is not derived from ‘const std::complex<_Tp>’ 13 | return s.lower_bound(x) - s.begin(); | ^ /usr/include/c++/13/complex:383:5: note: candidate: ‘template<class _Tp> constexpr std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)’ 383 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/13/complex:383:5: note: template argument deduction/substitution failed: answer.code:13:43: note: ‘std::set<long long int>::iterator’ {aka ‘std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator’} is not derived from ‘const std::complex<_Tp>’ 13 | return s.lower_bound(x) - s.begin(); | ^ /usr/include/c++/13/complex:460:5: note: candidate: ‘template...