QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601647#7787. Maximum RatingzhouxpCompile Error//C++142.2kb2024-09-30 09:48:012024-09-30 09:48:01

Judging History

你现在查看的是最新测评结果

  • [2024-09-30 09:48:01]
  • 评测
  • [2024-09-30 09:48:01]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
    int x=0,fz=1;
    char ch;
    while((ch=getchar())<'0'||ch>'9')if(ch=='-') fz=-1;
    while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
    return x*fz;
}
int n,m;
ll sum;
const int N=2e5;
int a[N+4];
int dis[4*N+4],cnt;
struct segtree{
    ll tri[4*N];
    int num[4*N];
    void Pushup(int rt){
        tri[rt]=tri[rt<<1]+tri[rt<<1|1];
        num[rt]=num[rt<<1]+num[rt<<1|1];
    }
    void Update(int rt,int l,int r,int x,int w){
        if(l==r){
            if(w) num[rt]++; else num[rt]--;
            tri[rt]=1ll*dis[l]*num[rt];
            return;
        }
        int mid=l+(r-l)/2;
        if(x<=mid) Update(rt<<1,l,mid,x,w);
        else Update(rt<<1|1,mid+1,r,x,w);
        Pushup(rt);
    }
    int Query(int rt,int l,int r,ll x){
        if(tri[rt]<x) return 0;
        if(l==r) return min(num[rt],x/dis[l]+(x%dis[l]!=0));
        int mid=l+(r-l)/2;
        if(tri[rt<<1|1]>=x) return Query(rt<<1|1,mid+1,r,x);
        else return num[rt<<1|1]+Query(rt<<1,l,mid,x-tri[rt<<1|1]);
    }
}t;
struct node{
    int v,w;
}q[N+4];
int main(){
    n=read(),m=read();
    for(int i=1;i<=n;i++){
        a[i]=read();
        if(a[i]>0) dis[++cnt]=a[i];
    }
    for(int i=1;i<=m;i++){
        q[i].v=read();q[i].w=read();
        if(q[i].w>0) dis[++cnt]=q[i].w;
    }
    sort(dis+1,dis+1+cnt);
    cnt=unique(dis+1,dis+1+cnt)-dis-1;
//    t.Build(1,1,m);
//    int sum=0;
	int neg=0;
    for(int i=1;i<=n;i++){
        sum+=a[i];
        if(a[i]>0){
            int now=lower_bound(dis+1,dis+1+cnt,a[i])-dis;
            t.Update(1,1,cnt,now,a[i]);
        }
    	else neg++;
    }
    for(int i=1;i<=m;i++){
        int v=q[i].v,w=q[i].w;
        if(w>0){
        	int x=lower_bound(dis+1,dis+1+cnt,w)-dis;
        	t.Update(1,1,cnt,x,w);
		}
		else neg++;
		if(a[v]>0){
			int y=lower_bound(dis+1,dis+1+cnt,a[v])-dis;
			t.Update(1,1,cnt,y,0);
		}
      	else neg--;
        sum-=a[v];sum+=w;
        a[v]=w;
        int ans;
		if(sum>0) ans=n-t.Query(1,1,cnt,sum)+1-neg;
		else ans=t.num[1]+1;
      //  if(sum<0&&t.num[1]) ans++;
        printf("%d\n",ans);
    }
    return 0;
}

Details

answer.code: In member function ‘int segtree::Query(int, int, int, long long int)’:
answer.code:36:28: error: no matching function for call to ‘min(int&, long long int)’
   36 |         if(l==r) return min(num[rt],x/dis[l]+(x%dis[l]!=0));
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included 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_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:36:28: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   36 |         if(l==r) return min(num[rt],x/dis[l]+(x%dis[l]!=0));
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:36:28: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   36 |         if(l==r) return min(num[rt],x/dis[l]+(x%dis[l]!=0));
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:36:28: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   36 |         if(l==r) return min(num[rt],x/dis[l]+(x%dis[l]!=0));
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:36:28: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   36 |         if(l==r) return min(num[rt],x/dis[l]+(x%dis[l]!=0));
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~