답안 #1114959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114959 2024-11-19T20:57:16 Z Marco_Escandon 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
struct st{
    vector<ll> cad;
    void update(ll a, ll b)
    {
        for(a; a<cad.size(); a+=(a&-a)) cad[a]+=b;
    }
    ll query(ll a)
    {
        ll s=0;
        for(a; a>0; a-=(a&-a)) s+=cad[a];
        return s;
    }
    ll query(ll a, ll b) {return query(b)-query(a-1);}
    st(ll n){ cad.resize(n+5);}
}asd(300000);
int main()
{
    ll n,k,c=1;
    cin>>n>>k>>k;
    ordered_set s;
    ll cad[n];
    vector<ll>asdf;
    map<ll,ll> mapa;
    for(int i=0; i<n; i++)
    {
        cin>>cad[i];        
        asdf.push_back(cad[i]);
    }
    sort(asdf.begin(),asdf.end());
    for(auto i:asdf){if(mapa[i]==0){mapa[i]=c++;}}
    ll z=0;
    ll bs=0;
    for(int i=0; i<n; i++)
    {
        s.insert(cad[i]);
        asd.update(mapa[cad[i]],cad[i]);
 
        ll mediana = *s.find_by_order((s.size()-1)/2);
        ll temp=s.order_of_key(mediana);

        while(temp*mediana-asd.query(mapa[mediana]-1)+asd.query(mapa[mediana],300000)-(k-temp)*mediana>k)
        {
            s.erase(s.find_by_order(s.order_of_key(cad[z])));
            asd.update(mapa[cad[z]],-cad[z]);
            z++;
        }
        bs=max(bs,(ll)s.size());
    }
    cout<<bs;
}

Compilation message

ricehub.cpp: In member function 'void st::update(ll, ll)':
ricehub.cpp:13:13: warning: statement has no effect [-Wunused-value]
   13 |         for(a; a<cad.size(); a+=(a&-a)) cad[a]+=b;
      |             ^
ricehub.cpp:13:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for(a; a<cad.size(); a+=(a&-a)) cad[a]+=b;
      |                ~^~~~~~~~~~~
ricehub.cpp: In member function 'll st::query(ll)':
ricehub.cpp:18:13: warning: statement has no effect [-Wunused-value]
   18 |         for(a; a>0; a-=(a&-a)) s+=cad[a];
      |             ^
/usr/bin/ld: /tmp/ccC3EYL4.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccOjkQi0.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccC3EYL4.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status