답안 #909529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909529 2024-01-17T08:45:25 Z Tuanlinh123 Fish 2 (JOI22_fish2) C++17
100 / 100
946 ms 56404 KB
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

ll x[100005];

struct SegTree
{
    struct Node
    {
        ll ans=0, sum=0, len;
        vector <pair<ll, pll>> pre, suf;

        Node(){}
        Node(ll x)
        {
            ans=1, sum=x, len=1;
            pre.pb({0, {x, 0}});
            suf.pb({0, {x, 0}});
        }
    };

    Node Merge(Node a, Node b)
    {
        Node ans;
        ans.sum=a.sum+b.sum, ans.len=a.len+b.len;
        ans.pre=vector <pair<ll, pll>> (a.pre.begin(), a.pre.end());
        ans.suf=vector <pair<ll, pll>> (b.suf.begin(), b.suf.end());
        ll resa=a.ans, resb=b.ans, reqa=0, reqb=0;
        for (pair<ll, pll> p:a.suf)
            reqb=max(reqb, p.se.fi-p.fi);
        for (pair<ll, pll> p:b.pre)
            reqa=max(reqa, p.se.fi-p.fi);
        ll s=0, ptra=0, ptrb=0;
        for (ll i=0; i<b.pre.size(); i++)
        {
            pair<ll, pll> p=b.pre[i];
            if (a.sum+p.fi<p.se.fi)
            {
                while (ptrb<=i)
                {
                    while (1)
                    {
                        if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
                            ptrb++, s+=b.pre[ptrb].se.se;
                        else if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
                            ptra++;
                        else break;
                    }
                    if (ptrb==i)
                    {
                        ans.pre.pb({a.sum+p.fi, {p.se.fi, (ptra==a.suf.size()?s:0)}});
                        break;
                    }
                    ptrb++, s=(ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se);
                }
                if (resa)
                {
                    ll ptra=0, ptrb=0, s=0; resa=0;
                    while (1)
                    {
                        while (1)
                        {
                            if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
                                ptra++, s+=ptra==a.suf.size()?a.ans:a.suf[ptra].se.se;
                            else if (ptrb<i && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
                                ptrb++;
                            else break;
                        }
                        if (ptra==a.suf.size())
                        {
                            if (ptrb==i) ans.pre.back().se.se+=s;
                            break;
                        }
                        ptra++, s=ptra==a.suf.size()?a.ans:a.suf[ptra].se.se;
                    }
                }
            }

        }
        ptra=0, ptrb=0, s=0;
        for (ll i=0; i<a.suf.size(); i++)
        {
            pair<ll, pll> p=a.suf[i];
            if (p.fi+b.sum<p.se.fi)
            {
                while (ptra<=i)
                {
                    while (1)
                    {
                        if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
                            ptra++, s+=a.suf[ptra].se.se;
                        else if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
                            ptrb++;
                        else break;
                    }
                    if (ptra==i)
                    {
                        ans.suf.pb({p.fi+b.sum, {p.se.fi, (ptrb==b.pre.size()?s:0)}});
                        break;
                    }
                    ptra++, s=(ptra==a.suf.size()?a.ans:a.suf[ptra].se.se);
                }
                if (resb)
                {
                    ll ptra=0, ptrb=0, s=0; resb=0;
                    while (1)
                    {
                        while (1)
                        {
                            if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
                                ptrb++, s+=ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se;
                            else if (ptra<i && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
                                ptra++;
                            else break;
                        }
                        if (ptrb==b.pre.size())
                        {
                            if (ptra==i) ans.suf.back().se.se+=s;
                            break;
                        }
                        ptrb++, s=ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se;
                    }
                }
            }

        }
        ptra=0, ptrb=0, s=0;
        while (1)
        {
            while (1)
            {
                if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
                    ptra++, s+=ptra==a.suf.size()?a.ans:a.suf[ptra].se.se;
                else if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
                    ptrb++;
                else break;
            }   
            if (ptra==a.suf.size())
            {
                if (ptrb==b.pre.size())
                    ans.ans+=s;
                break;
            }
            ptra++, s=ptra==a.suf.size()?a.ans:a.suf[ptra].se.se;
        }
        ptra=0, ptrb=0, s=0;
        while (1)
        {
            while (1)
            {
                if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
                    ptrb++, s+=ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se;
                else if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
                    ptra++;
                else break;
            }    
            if (ptrb==b.pre.size())
            {
                if (ptra==a.suf.size())
                    ans.ans+=s;
                break;
            }
            ptrb++, s=ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se;
        }
        // if (a.len!=0 && b.len!=0)
        // {
        //     cout << a.len << " " << b.len << " " << a.ans << " " << b.ans << " " << a.sum << " " << b.sum << "\n"; 
        //     for (pair<ll, pll> i:a.suf) cout << i.fi << " " << i.se.fi << " " << i.se.se << "\n";
        //     for (pair<ll, pll> i:b.pre) cout << i.fi << " " << i.se.fi << " " << i.se.se << "\n";
        //     cout << "ans " << resa << " " << resb << " " << ans.ans << "\n";
        //     cout << "=>\n";
        //     for (pair<ll, pll> i:ans.pre) cout << i.fi << " " << i.se.fi << " " << i.se.se << "\n";
        // }
        return ans;
    }

    void build(ll i, ll Start, ll End)
    {
        if (Start==End)
        {
            St[i]=Node(x[Start]);
            return;
        }
        ll mid=(Start+End)/2;
        build(i*2, Start, mid);
        build(i*2+1, mid+1, End);
        St[i]=Merge(St[i*2], St[i*2+1]);
    }

    ll n;
    vector <Node> St;
    SegTree (ll n): n(n)
    {
        St.resize(n*4+1);
        build(1, 1, n);
    }

    void update(ll i, ll Start, ll End, ll idx, ll x)
    {
        if (Start>idx || End<idx)
            return;
        if (Start==End)
        {
            St[i]=Node(x);
            return;
        }
        ll mid=(Start+End)/2;
        update(i*2, Start, mid, idx, x);
        update(i*2+1, mid+1, End, idx, x);
        St[i]=Merge(St[i*2], St[i*2+1]);
    }

    Node query(ll i, ll Start, ll End, ll l, ll r)
    {
        if (Start>=l && End<=r)
            return St[i];
        ll mid=(Start+End)/2;
        if (mid<l) return query(i*2+1, mid+1, End, l, r);
        if (mid+1>r) return query(i*2, Start, mid, l, r);
        return Merge(query(i*2, Start, mid, l, r), query(i*2+1, mid+1, End, l, r));
    }
};


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    for (ll i=1; i<=n; i++)
        cin >> x[i];
    SegTree A(n);
    ll q; cin >> q;
    for (ll i=1; i<=q; i++)
    {
        ll t, a, b; cin >> t >> a >> b;
        if (t==1) A.update(1, 1, n, a, b);
        else cout << A.query(1, 1, n, a, b).ans << "\n";
    }
}

Compilation message

fish2.cpp: In member function 'SegTree::Node SegTree::Merge(SegTree::Node, SegTree::Node)':
fish2.cpp:41:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for (ll i=0; i<b.pre.size(); i++)
      |                      ~^~~~~~~~~~~~~
fish2.cpp:50:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |                         if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                             ~~~~^~~~~~~~~~~~~
fish2.cpp:50:70: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |                         if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                                                                  ~~~~^~~~~~~~~~~~~~
fish2.cpp:52:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                         else if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                                  ~~~~^~~~~~~~~~~~~
fish2.cpp:52:75: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                         else if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                                                                       ~~~~^~~~~~~~~~~~~~
fish2.cpp:58:64: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |                         ans.pre.pb({a.sum+p.fi, {p.se.fi, (ptra==a.suf.size()?s:0)}});
      |                                                            ~~~~^~~~~~~~~~~~~~
fish2.cpp:61:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |                     ptrb++, s=(ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se);
      |                                ~~~~^~~~~~~~~~~~~~
fish2.cpp:70:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |                             if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                                 ~~~~^~~~~~~~~~~~~
fish2.cpp:70:74: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |                             if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                                                                      ~~~~^~~~~~~~~~~~~~
fish2.cpp:71:48: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |                                 ptra++, s+=ptra==a.suf.size()?a.ans:a.suf[ptra].se.se;
      |                                            ~~~~^~~~~~~~~~~~~~
fish2.cpp:72:68: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |                             else if (ptrb<i && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                                                                ~~~~^~~~~~~~~~~~~~
fish2.cpp:76:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |                         if (ptra==a.suf.size())
      |                             ~~~~^~~~~~~~~~~~~~
fish2.cpp:81:39: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |                         ptra++, s=ptra==a.suf.size()?a.ans:a.suf[ptra].se.se;
      |                                   ~~~~^~~~~~~~~~~~~~
fish2.cpp:88:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |         for (ll i=0; i<a.suf.size(); i++)
      |                      ~^~~~~~~~~~~~~
fish2.cpp:97:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |                         if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                             ~~~~^~~~~~~~~~~~~
fish2.cpp:97:70: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |                         if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                                                                  ~~~~^~~~~~~~~~~~~~
fish2.cpp:99:38: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |                         else if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                                  ~~~~^~~~~~~~~~~~~
fish2.cpp:99:75: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |                         else if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                                                                       ~~~~^~~~~~~~~~~~~~
fish2.cpp:105:64: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |                         ans.suf.pb({p.fi+b.sum, {p.se.fi, (ptrb==b.pre.size()?s:0)}});
      |                                                            ~~~~^~~~~~~~~~~~~~
fish2.cpp:108:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  108 |                     ptra++, s=(ptra==a.suf.size()?a.ans:a.suf[ptra].se.se);
      |                                ~~~~^~~~~~~~~~~~~~
fish2.cpp:117:37: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  117 |                             if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                                 ~~~~^~~~~~~~~~~~~
fish2.cpp:117:74: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  117 |                             if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                                                                      ~~~~^~~~~~~~~~~~~~
fish2.cpp:118:48: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  118 |                                 ptrb++, s+=ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se;
      |                                            ~~~~^~~~~~~~~~~~~~
fish2.cpp:119:68: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  119 |                             else if (ptra<i && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                                                                ~~~~^~~~~~~~~~~~~~
fish2.cpp:123:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  123 |                         if (ptrb==b.pre.size())
      |                             ~~~~^~~~~~~~~~~~~~
fish2.cpp:128:39: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  128 |                         ptrb++, s=ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se;
      |                                   ~~~~^~~~~~~~~~~~~~
fish2.cpp:139:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |                 if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                     ~~~~^~~~~~~~~~~~~
fish2.cpp:139:62: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |                 if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                                                          ~~~~^~~~~~~~~~~~~~
fish2.cpp:140:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  140 |                     ptra++, s+=ptra==a.suf.size()?a.ans:a.suf[ptra].se.se;
      |                                ~~~~^~~~~~~~~~~~~~
fish2.cpp:141:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  141 |                 else if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                          ~~~~^~~~~~~~~~~~~
fish2.cpp:141:67: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  141 |                 else if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                                                               ~~~~^~~~~~~~~~~~~~
fish2.cpp:145:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  145 |             if (ptra==a.suf.size())
      |                 ~~~~^~~~~~~~~~~~~~
fish2.cpp:147:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  147 |                 if (ptrb==b.pre.size())
      |                     ~~~~^~~~~~~~~~~~~~
fish2.cpp:151:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  151 |             ptra++, s=ptra==a.suf.size()?a.ans:a.suf[ptra].se.se;
      |                       ~~~~^~~~~~~~~~~~~~
fish2.cpp:158:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  158 |                 if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                     ~~~~^~~~~~~~~~~~~
fish2.cpp:158:62: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  158 |                 if (ptrb<b.pre.size() && b.pre[ptrb].fi+(ptra==a.suf.size()?a.sum:a.suf[ptra].fi)>=b.pre[ptrb].se.fi)
      |                                                          ~~~~^~~~~~~~~~~~~~
fish2.cpp:159:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  159 |                     ptrb++, s+=ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se;
      |                                ~~~~^~~~~~~~~~~~~~
fish2.cpp:160:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  160 |                 else if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                          ~~~~^~~~~~~~~~~~~
fish2.cpp:160:67: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  160 |                 else if (ptra<a.suf.size() && a.suf[ptra].fi+(ptrb==b.pre.size()?b.sum:b.pre[ptrb].fi)>=a.suf[ptra].se.fi)
      |                                                               ~~~~^~~~~~~~~~~~~~
fish2.cpp:164:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  164 |             if (ptrb==b.pre.size())
      |                 ~~~~^~~~~~~~~~~~~~
fish2.cpp:166:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  166 |                 if (ptra==a.suf.size())
      |                     ~~~~^~~~~~~~~~~~~~
fish2.cpp:170:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  170 |             ptrb++, s=ptrb==b.pre.size()?b.ans:b.pre[ptrb].se.se;
      |                       ~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 696 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 82 ms 53484 KB Output is correct
3 Correct 85 ms 52052 KB Output is correct
4 Correct 79 ms 53216 KB Output is correct
5 Correct 81 ms 52104 KB Output is correct
6 Correct 77 ms 46792 KB Output is correct
7 Correct 69 ms 46160 KB Output is correct
8 Correct 79 ms 46676 KB Output is correct
9 Correct 70 ms 46164 KB Output is correct
10 Correct 81 ms 54288 KB Output is correct
11 Correct 80 ms 50336 KB Output is correct
12 Correct 67 ms 45652 KB Output is correct
13 Correct 78 ms 45768 KB Output is correct
14 Correct 72 ms 47444 KB Output is correct
15 Correct 76 ms 47952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 696 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 82 ms 53484 KB Output is correct
23 Correct 85 ms 52052 KB Output is correct
24 Correct 79 ms 53216 KB Output is correct
25 Correct 81 ms 52104 KB Output is correct
26 Correct 77 ms 46792 KB Output is correct
27 Correct 69 ms 46160 KB Output is correct
28 Correct 79 ms 46676 KB Output is correct
29 Correct 70 ms 46164 KB Output is correct
30 Correct 81 ms 54288 KB Output is correct
31 Correct 80 ms 50336 KB Output is correct
32 Correct 67 ms 45652 KB Output is correct
33 Correct 78 ms 45768 KB Output is correct
34 Correct 72 ms 47444 KB Output is correct
35 Correct 76 ms 47952 KB Output is correct
36 Correct 85 ms 53588 KB Output is correct
37 Correct 93 ms 52088 KB Output is correct
38 Correct 88 ms 52052 KB Output is correct
39 Correct 92 ms 53520 KB Output is correct
40 Correct 92 ms 52052 KB Output is correct
41 Correct 71 ms 46628 KB Output is correct
42 Correct 74 ms 46676 KB Output is correct
43 Correct 79 ms 46208 KB Output is correct
44 Correct 76 ms 46160 KB Output is correct
45 Correct 101 ms 54612 KB Output is correct
46 Correct 95 ms 54352 KB Output is correct
47 Correct 85 ms 49280 KB Output is correct
48 Correct 69 ms 45904 KB Output is correct
49 Correct 74 ms 45952 KB Output is correct
50 Correct 75 ms 47544 KB Output is correct
51 Correct 82 ms 47956 KB Output is correct
52 Correct 80 ms 47464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 82 ms 53484 KB Output is correct
3 Correct 85 ms 52052 KB Output is correct
4 Correct 79 ms 53216 KB Output is correct
5 Correct 81 ms 52104 KB Output is correct
6 Correct 77 ms 46792 KB Output is correct
7 Correct 69 ms 46160 KB Output is correct
8 Correct 79 ms 46676 KB Output is correct
9 Correct 70 ms 46164 KB Output is correct
10 Correct 81 ms 54288 KB Output is correct
11 Correct 80 ms 50336 KB Output is correct
12 Correct 67 ms 45652 KB Output is correct
13 Correct 78 ms 45768 KB Output is correct
14 Correct 72 ms 47444 KB Output is correct
15 Correct 76 ms 47952 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 743 ms 53920 KB Output is correct
18 Correct 716 ms 55868 KB Output is correct
19 Correct 750 ms 53932 KB Output is correct
20 Correct 793 ms 53580 KB Output is correct
21 Correct 809 ms 53800 KB Output is correct
22 Correct 672 ms 55140 KB Output is correct
23 Correct 766 ms 53400 KB Output is correct
24 Correct 777 ms 53788 KB Output is correct
25 Correct 754 ms 54064 KB Output is correct
26 Correct 783 ms 54196 KB Output is correct
27 Correct 429 ms 48740 KB Output is correct
28 Correct 467 ms 48540 KB Output is correct
29 Correct 443 ms 48720 KB Output is correct
30 Correct 554 ms 47700 KB Output is correct
31 Correct 645 ms 47692 KB Output is correct
32 Correct 799 ms 51968 KB Output is correct
33 Correct 791 ms 56404 KB Output is correct
34 Correct 805 ms 51572 KB Output is correct
35 Correct 791 ms 50560 KB Output is correct
36 Correct 783 ms 56148 KB Output is correct
37 Correct 425 ms 47272 KB Output is correct
38 Correct 370 ms 47324 KB Output is correct
39 Correct 506 ms 49404 KB Output is correct
40 Correct 454 ms 49744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 82 ms 53484 KB Output is correct
3 Correct 85 ms 52052 KB Output is correct
4 Correct 79 ms 53216 KB Output is correct
5 Correct 81 ms 52104 KB Output is correct
6 Correct 77 ms 46792 KB Output is correct
7 Correct 69 ms 46160 KB Output is correct
8 Correct 79 ms 46676 KB Output is correct
9 Correct 70 ms 46164 KB Output is correct
10 Correct 81 ms 54288 KB Output is correct
11 Correct 80 ms 50336 KB Output is correct
12 Correct 67 ms 45652 KB Output is correct
13 Correct 78 ms 45768 KB Output is correct
14 Correct 72 ms 47444 KB Output is correct
15 Correct 76 ms 47952 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 900 ms 54568 KB Output is correct
18 Correct 946 ms 54096 KB Output is correct
19 Correct 539 ms 53220 KB Output is correct
20 Correct 690 ms 53908 KB Output is correct
21 Correct 777 ms 54480 KB Output is correct
22 Correct 873 ms 54056 KB Output is correct
23 Correct 742 ms 53068 KB Output is correct
24 Correct 823 ms 54008 KB Output is correct
25 Correct 673 ms 53300 KB Output is correct
26 Correct 576 ms 48644 KB Output is correct
27 Correct 751 ms 48652 KB Output is correct
28 Correct 589 ms 49748 KB Output is correct
29 Correct 603 ms 48616 KB Output is correct
30 Correct 752 ms 48524 KB Output is correct
31 Correct 767 ms 49748 KB Output is correct
32 Correct 865 ms 52312 KB Output is correct
33 Correct 578 ms 51544 KB Output is correct
34 Correct 789 ms 55988 KB Output is correct
35 Correct 461 ms 55712 KB Output is correct
36 Correct 694 ms 51500 KB Output is correct
37 Correct 679 ms 50188 KB Output is correct
38 Correct 485 ms 50036 KB Output is correct
39 Correct 616 ms 49564 KB Output is correct
40 Correct 245 ms 49492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 696 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 82 ms 53484 KB Output is correct
23 Correct 85 ms 52052 KB Output is correct
24 Correct 79 ms 53216 KB Output is correct
25 Correct 81 ms 52104 KB Output is correct
26 Correct 77 ms 46792 KB Output is correct
27 Correct 69 ms 46160 KB Output is correct
28 Correct 79 ms 46676 KB Output is correct
29 Correct 70 ms 46164 KB Output is correct
30 Correct 81 ms 54288 KB Output is correct
31 Correct 80 ms 50336 KB Output is correct
32 Correct 67 ms 45652 KB Output is correct
33 Correct 78 ms 45768 KB Output is correct
34 Correct 72 ms 47444 KB Output is correct
35 Correct 76 ms 47952 KB Output is correct
36 Correct 85 ms 53588 KB Output is correct
37 Correct 93 ms 52088 KB Output is correct
38 Correct 88 ms 52052 KB Output is correct
39 Correct 92 ms 53520 KB Output is correct
40 Correct 92 ms 52052 KB Output is correct
41 Correct 71 ms 46628 KB Output is correct
42 Correct 74 ms 46676 KB Output is correct
43 Correct 79 ms 46208 KB Output is correct
44 Correct 76 ms 46160 KB Output is correct
45 Correct 101 ms 54612 KB Output is correct
46 Correct 95 ms 54352 KB Output is correct
47 Correct 85 ms 49280 KB Output is correct
48 Correct 69 ms 45904 KB Output is correct
49 Correct 74 ms 45952 KB Output is correct
50 Correct 75 ms 47544 KB Output is correct
51 Correct 82 ms 47956 KB Output is correct
52 Correct 80 ms 47464 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 743 ms 53920 KB Output is correct
55 Correct 716 ms 55868 KB Output is correct
56 Correct 750 ms 53932 KB Output is correct
57 Correct 793 ms 53580 KB Output is correct
58 Correct 809 ms 53800 KB Output is correct
59 Correct 672 ms 55140 KB Output is correct
60 Correct 766 ms 53400 KB Output is correct
61 Correct 777 ms 53788 KB Output is correct
62 Correct 754 ms 54064 KB Output is correct
63 Correct 783 ms 54196 KB Output is correct
64 Correct 429 ms 48740 KB Output is correct
65 Correct 467 ms 48540 KB Output is correct
66 Correct 443 ms 48720 KB Output is correct
67 Correct 554 ms 47700 KB Output is correct
68 Correct 645 ms 47692 KB Output is correct
69 Correct 799 ms 51968 KB Output is correct
70 Correct 791 ms 56404 KB Output is correct
71 Correct 805 ms 51572 KB Output is correct
72 Correct 791 ms 50560 KB Output is correct
73 Correct 783 ms 56148 KB Output is correct
74 Correct 425 ms 47272 KB Output is correct
75 Correct 370 ms 47324 KB Output is correct
76 Correct 506 ms 49404 KB Output is correct
77 Correct 454 ms 49744 KB Output is correct
78 Correct 1 ms 344 KB Output is correct
79 Correct 900 ms 54568 KB Output is correct
80 Correct 946 ms 54096 KB Output is correct
81 Correct 539 ms 53220 KB Output is correct
82 Correct 690 ms 53908 KB Output is correct
83 Correct 777 ms 54480 KB Output is correct
84 Correct 873 ms 54056 KB Output is correct
85 Correct 742 ms 53068 KB Output is correct
86 Correct 823 ms 54008 KB Output is correct
87 Correct 673 ms 53300 KB Output is correct
88 Correct 576 ms 48644 KB Output is correct
89 Correct 751 ms 48652 KB Output is correct
90 Correct 589 ms 49748 KB Output is correct
91 Correct 603 ms 48616 KB Output is correct
92 Correct 752 ms 48524 KB Output is correct
93 Correct 767 ms 49748 KB Output is correct
94 Correct 865 ms 52312 KB Output is correct
95 Correct 578 ms 51544 KB Output is correct
96 Correct 789 ms 55988 KB Output is correct
97 Correct 461 ms 55712 KB Output is correct
98 Correct 694 ms 51500 KB Output is correct
99 Correct 679 ms 50188 KB Output is correct
100 Correct 485 ms 50036 KB Output is correct
101 Correct 616 ms 49564 KB Output is correct
102 Correct 245 ms 49492 KB Output is correct
103 Correct 898 ms 53220 KB Output is correct
104 Correct 919 ms 55196 KB Output is correct
105 Correct 820 ms 53968 KB Output is correct
106 Correct 789 ms 54056 KB Output is correct
107 Correct 869 ms 53452 KB Output is correct
108 Correct 920 ms 55276 KB Output is correct
109 Correct 884 ms 53444 KB Output is correct
110 Correct 748 ms 53816 KB Output is correct
111 Correct 795 ms 54012 KB Output is correct
112 Correct 682 ms 53892 KB Output is correct
113 Correct 730 ms 48464 KB Output is correct
114 Correct 531 ms 48720 KB Output is correct
115 Correct 694 ms 49748 KB Output is correct
116 Correct 721 ms 50216 KB Output is correct
117 Correct 495 ms 48580 KB Output is correct
118 Correct 639 ms 49268 KB Output is correct
119 Correct 688 ms 48720 KB Output is correct
120 Correct 784 ms 50016 KB Output is correct
121 Correct 687 ms 49828 KB Output is correct
122 Correct 859 ms 52460 KB Output is correct
123 Correct 733 ms 51680 KB Output is correct
124 Correct 692 ms 50708 KB Output is correct
125 Correct 747 ms 50288 KB Output is correct
126 Correct 710 ms 50700 KB Output is correct
127 Correct 704 ms 50276 KB Output is correct
128 Correct 492 ms 49012 KB Output is correct
129 Correct 652 ms 49664 KB Output is correct
130 Correct 525 ms 50068 KB Output is correct