답안 #939860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939860 2024-03-06T20:51:15 Z n3rm1n 푸드 코트 (JOI21_foodcourt) C++17
0 / 100
1000 ms 12100 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const long long MAXN = 3e5 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long n, m, que;
/*vector < pair < long long , long long> > q[MAXN];
vector < long long > pref[MAXN];*/
long long total[MAXN];
long long type;
long long l, r, c, k, a, b;

long long t[MAXN * 4];
pair < int, int > lazy[MAXN * 4];

void push_lazy(long long i, long long l, long long r)
{
    if(lazy[i].first == 1)
        t[i] += (r - l + 1) * lazy[i].second;
    else if(lazy[i].first == 2)
        t[i] = max(1LL * 0, t[i] - (r - l + 1) * lazy[i].second);
    if(lazy[i].first && l != r)
    {
        int mid = (l + r)/2;
        push_lazy(2*i, l, mid);
        push_lazy(2*i+1, mid+1, r);
        lazy[2*i] = lazy[i];
        lazy[2*i+1] = lazy[i];
    }
    lazy[i] = {0, 0};
}
long long ql, qr, type_update, val;
long long query(long long i, long long l, long long r)
{
    push_lazy(i, l, r);
    if(ql <= l && r <= qr)return t[i];
    if(qr < l || r < ql)return 0;
    long long mid = (l + r)/2;
    return query(2*i, l, mid) + query(2*i+1, mid+1, r);
}
void update(long long i, long long l, long long r)
{
    push_lazy(i, l, r);
    if(qr < l || ql > r)return;
    if(ql <= l && r <= qr)
    {
        lazy[i].first  = type_update;
        lazy[i].second += val;
        push_lazy(i, l, r);
        return;
    }
    long long mid = (l + r)/2;
    update(2*i, l, mid);
    update(2*i+1, mid+1, r);
    t[i] = t[2*i] + t[2*i+1];
}

void read()
{
    cin >> n >> m >> que;
    long long last_add = 0;
    for (long long i = 1; i <= que; ++ i)
    {
        cin >> type;
        if(type == 1)
        {
            cin >> l >> r >> c >> k;
            ql = l;
            qr = r;

            type_update = 1;
            val = k;
            update(1, 1, n);
            //cout << "ended " << endl;
        }
        else if(type == 2)
        {
            cin >> l >> r >> k;

                ql = l;
                qr = r;
                val = k;
                type_update = 2;
                update(1, 1, n);


        }
        else
        {
            cin >> a >> b;
            ql = a;
            qr = a;
            int sum = query(1, 1, n);
            if(sum < b)
            {
                cout << 0 << endl;
                continue;
            }
           else cout << 1 << endl;
        }
    }
}
int main()
{
    speed();

    read();
	return 0;
}

Compilation message

foodcourt.cpp: In function 'void read()':
foodcourt.cpp:66:15: warning: unused variable 'last_add' [-Wunused-variable]
   66 |     long long last_add = 0;
      |               ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1056 ms 5116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1051 ms 12100 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1061 ms 4948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -