답안 #1010683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010683 2024-06-29T09:31:58 Z modwwe Two Dishes (JOI19_dishes) C++17
0 / 100
156 ms 39068 KB
//https://www.instagram.com/_modwwe/
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const int inf=1e18;
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    int a,b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c, d,e,f;

};
int n,m,s0,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l,l2,r2;
int  i,s10,s12;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
///     fin(task),fou(task);
#endif
    NHP
    /// cin>>s1;
    // modwwe
    phongbeo(),down
}
ic a[1000007];
ic b[1000007];
ic c[1000007];
ic d[1000007];
struct fen_wick
{
    int bit[1000007];
    void upd(int x,int y)
    {
        for(x; x; x-=x&-x) bit[x]+=y;
    }
    int get(int x)
    {
        int s=0;
        for(x; x<=max(n,m); x+=x&-x)s+=bit[x];
        return s;
    }
} fen[4];
bool cmp(ic a,ic b)
{
    return a.c<b.c;
}

void phongbeo()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>a[i].a>>a[i].b>>a[i].c,
            a[i].a+=a[i-1].a,
                    c[i]= {a[i].b-a[i].a,a[i].c,i},
                          fen[0].upd(i,a[i].c),
                          fen[2].upd(i,a[i].c);

    for(int i=1; i<=m; i++)
        cin>>b[i].a>>b[i].b>>b[i].c,
            b[i].a+=b[i-1].a,
                    d[i]= {b[i].b-b[i].a,b[i].c,i},
                          fen[1].upd(i,b[i].c),
                          fen[3].upd(i,b[i].c);
    sort(c+1,c+1+n,cmp);
    sort(d+1,d+1+m,cmp);
    l=1;
    l2=1;
    r=0;
    r2=0;

    while(c[l].a<b[1].a&&l<=n)
    {
        fen[2].upd(c[l].c,-c[l].b);
        if(c[l].a<0)fen[0].upd(c[l].c,-c[l].b);
        l++;
    }
    while(d[l2].a<a[1].a&&l2<=m)
    {
        fen[3].upd(d[l2].c,-d[l2].b);
        if(d[l2].a<0)        fen[1].upd(d[l2].c,-d[l2].b);

        l2++;
    }
    s2=fen[2].get(1);
    s0=fen[0].get(1);
    s1=fen[1].get(1);
    s3=fen[3].get(1);
    for(int i=1; i<=n+m; i++)
    {
        if(s0-s2<=s1-s3)
        {
            r2++;
            while(c[l].a<b[r2+1].a&&l<=n)
            {
                fen[2].upd(c[l].c,-c[l].b);
                if(c[l].a<b[r2].a)fen[0].upd(c[l].c,-c[l].b);
                l++;
            }

            s2=fen[2].get(r+1);
            s0=fen[0].get(r+1);
            s1=fen[1].get(r2+1);
            s3=fen[3].get(r2+1);
            if(r==n)
            {
                s1=inf;
                s3=-inf;
            }
            if(r2==m)
            {
                s0=inf;
                s2=-inf;
            }
            if(b[r2].a+a[r].a<=b[r2].b)s7+=b[r2].c;
        }
        else
        {
            r++;
            while(d[l2].a<a[r+1].a&&l2<=m)
            {
                fen[3].upd(d[l2].c,-d[l2].b);
                if(d[l2].a<a[r].a) fen[1].upd(d[l2].c,-d[l2].b);;
                l2++;
            }
            s2=fen[2].get(r+1);
            s0=fen[0].get(r+1);
            s1=fen[1].get(r2+1);
            s3=fen[3].get(r2+1);
            if(r2==m)
            {
                s0=inf;
                s2=-inf;
            }
            if(r==n)
            {
                s1=inf;
                s3=-inf;
            }
            if(b[r2].a+a[r].a<=a[r].b)s7+=a[r].c;
        }
    }
    cout<<s7;
}

Compilation message

dishes.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main()
      | ^~~~
dishes.cpp: In member function 'void fen_wick::upd(long long int, long long int)':
dishes.cpp:67:13: warning: statement has no effect [-Wunused-value]
   67 |         for(x; x; x-=x&-x) bit[x]+=y;
      |             ^
dishes.cpp: In member function 'long long int fen_wick::get(long long int)':
dishes.cpp:72:13: warning: statement has no effect [-Wunused-value]
   72 |         for(x; x<=max(n,m); x+=x&-x)s+=bit[x];
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 39068 KB Output is correct
2 Incorrect 148 ms 38804 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 468 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 468 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 468 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 468 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 468 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 39068 KB Output is correct
2 Incorrect 148 ms 38804 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 39068 KB Output is correct
2 Incorrect 148 ms 38804 KB Output isn't correct
3 Halted 0 ms 0 KB -