답안 #442644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
442644 2021-07-08T12:15:04 Z leaked 금 캐기 (IZhO14_divide) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("-O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define vec vector
#define sz(x) ( int)x.size()
#define m_p make_pair
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

using namespace std;

typedef long long ll;
typedef pair<ll, int> pli;
typedef pair<int,ll> pil;
typedef pair<int,int> pii;
typedef unsigned long long ull;
auto rng=bind(uniform_int_distribution<int>(1,1000),mt19937(time(0)));
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
vec<ll>kek;
const int N=1e5+1;
ll f[N];
void upd(int id,int x){
    id++;
    while(id<N){
        umax(f[id],x);
        id+=id&-id;
    }
}
int get(int id){
    id++;
    int ans=-2e9;
    while(id>0){
        umax(ans,f[id]);
        id-=id&-id;
    }
    return ans;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vec<int>x(n),g(n),d(n);
    vec<ll>pref(n,0);
    vec<ll>pg(n,0);
    for(int i=0;i<n;i++){
        cin>>x[i]>>g[i]>>d[i];
        pref[i]=(i?pref[i-1]:0)+d[i];
        pg[i]=(i?pg[i-1]:0)+g[i];
    }
    for(int i=0;i<n;i++){
        kek.pb(x[i]-pref[i]);
    }
    sort(all(kek));kek.erase(unique(all(kek)),kek.end());
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        int w=lower_bound(all(kek),x[i]-pref[i])-kek.begin();
//        cerr<<x[i]-pref[i]<<endl;
        upd(w,pg[i]);
        w=upper_bound(all(kek),x[i]-(i?pref[i-1]:0))-kek.begin()-1;
        umax(ans,get(w)-(i?pg[i-1]:0));
    }
    cout<<ans;
    return 0;
}

/*
1 5
8
4 2 5 1 3

2 4
4 5
2 2 1 4
*/

Compilation message

divide.cpp: In function 'void upd(int, int)':
divide.cpp:31:21: error: no matching function for call to 'umax(ll&, int&)'
   31 |         umax(f[id],x);
      |                     ^
divide.cpp:23:24: note: candidate: 'template<class T> bool umax(T&, const T&)'
   23 | template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
      |                        ^~~~
divide.cpp:23:24: note:   template argument deduction/substitution failed:
divide.cpp:31:21: note:   deduced conflicting types for parameter 'const T' ('long long int' and 'int')
   31 |         umax(f[id],x);
      |                     ^
divide.cpp: In function 'int get(int)':
divide.cpp:39:23: error: no matching function for call to 'umax(int&, ll&)'
   39 |         umax(ans,f[id]);
      |                       ^
divide.cpp:23:24: note: candidate: 'template<class T> bool umax(T&, const T&)'
   23 | template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
      |                        ^~~~
divide.cpp:23:24: note:   template argument deduction/substitution failed:
divide.cpp:39:23: note:   deduced conflicting types for parameter 'const T' ('int' and 'll' {aka 'long long int'})
   39 |         umax(ans,f[id]);
      |                       ^