QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#370434#4233. ResetInfinityNSCompile Error//C++202.0kb2024-03-29 07:32:082024-03-29 07:32:08

Judging History

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

  • [2024-03-29 07:32:08]
  • 评测
  • [2024-03-29 07:32:08]
  • 提交

answer

#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;

const int mod=998244353;
inline int add(int x,int y){int ret=x+y;if(ret>=mod)ret-=mod;return ret;}
inline int sub(int x,int y){int ret=x-y;if(ret<0)ret+=mod;return ret;}
inline int mul(int x,int y){return ((ll)x*y)%mod;}
inline int step(int base,int pw){int ret=1;while(pw){if(pw&1)ret=mul(ret,base);base=mul(base,base);pw>>=1;}return ret;}
inline int invv(int x){return step(x,mod-2);}


const int maxn=2e5+10;

ll c,n,t[maxn],d[maxn];

using int128=__int128_t;
typedef pair<ll,ll> pll;
bool check(ll mid){

    int128 total=min(((int128)mid+1)*min(n,c),(ll)1e18);
    multiset<pair<pll,ll>>st;

    for(int i=1;i<=n;i++){
        st.insert({ {d[i],t[i]},0 });
    }

    ll sum=0;
    ll cpc=c;
    while(st.size() && total>0){

        pair<pll,ll>x=(*st.rbegin());
        st.erase(st.find(x));

        int128 d=min(min(total,(int128)x.ff.ss/x.ff.ff), (int128)mid+1-x.ss );

        ///printf("%lld %lld %lld\n",d,x.ff.ff,x.ff.ss);

        x.ss+=d;
        x.ff.ss-=d*x.ff.ff;
        total-=d;
        x.ff.ff=min(x.ff.ff,x.ff.ss);

        if(x.ss==mid+1 || x.ff.ss==0){
            sum+=x.ff.ss;
            ///printf("%lld CPC\n",cpc);
            if(x.ss==mid+1)cpc--;
            continue;
        }
        st.insert(x);
    }
    while(st.size()){
        sum+=(*st.begin()).ff.ss;
        st.erase(st.begin());
    }

    ///printf("%lld %lld AA\n",sum,cpc);

    return sum<=cpc;
}

int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%lld %lld",&n,&c);

    for(int i=1;i<=n;i++){
        scanf("%lld %lld",&t[i],&d[i]);
    }

    //check(249);
    //return 0;

    ll l=0;
    ll r=2e15;
    ll sr,ret=0;
    while(l<=r){
        sr=(l+r)/2;
        if(check(sr)){
            r=sr-1;
            ret=sr;
        }
        else l=sr+1;
    }
    printf("%lld\n",ret);

    return 0;
}

Details

answer.code: In function ‘bool check(ll)’:
answer.code:25:21: error: no matching function for call to ‘min(int128, ll)’
   25 |     int128 total=min(((int128)mid+1)*min(n,c),(ll)1e18);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:25:21: note:   deduced conflicting types for parameter ‘const _Tp’ (‘__int128’ and ‘ll’ {aka ‘long long int’})
   25 |     int128 total=min(((int128)mid+1)*min(n,c),(ll)1e18);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:25:21: note:   deduced conflicting types for parameter ‘const _Tp’ (‘__int128’ and ‘ll’ {aka ‘long long int’})
   25 |     int128 total=min(((int128)mid+1)*min(n,c),(ll)1e18);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:25:21: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘__int128’
   25 |     int128 total=min(((int128)mid+1)*min(n,c),(ll)1e18);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:25:21: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘__int128’
   25 |     int128 total=min(((int128)mid+1)*min(n,c),(ll)1e18);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:70:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   70 |     scanf("%lld %lld",&n,&c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:73:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   73 |         scanf("%lld %lld",&t[i],&d[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~