답안 #697743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
697743 2023-02-11T02:09:48 Z winthemcut3 A Game with Grundy (CCO20_day1problem1) C++14
0 / 25
2 ms 852 KB
#include <bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define fi   first
#define se   second
#define BIT(x, i) (((x) >> (i)) & 1)
#define f(x) f[int((x)+mxM+2)]
using namespace std;

/** END OF TEMPLATE **/

const int mxM = 1e6 + 2;
const int mxN = 1e5 + 5;
ll n, L, R, Y;
int f[mxM*2 + 10], num[mxN];
void update(ll x, ll v, ll h) {
    ll b = -(x*v);
    long double X = -(Y+b)*h;
    X = floor(1.0*X/v); X++;
    ll rX = x + (x - X) + 1;
    if(X < L) X = L;
    if(rX > R) rX = R+1;
    f(X)++; f(rX)--;
}

int main()
{
    FastIO;
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    cin >> n >> L >> R >> Y;
    FOR(i, 1, n) {
        ll x, v, h; cin >> x >> v >> h;
        update(x, v, h);
    }
    FOR(i, L, R) f(i) += f(i-1);
    FOR(i, L, R) num[f(i)]++;
    FOR(i, 1, n) num[i] += num[i-1];
    FOR(i, 0, n) cout << num[i] << ' ';

    return 0;
}

/*
y = 2/3x
3 => x =
y = 2x
y = ax + b
y = 2x + 8
3 + 8 = 2x


y = 2x - 8
y = 2x + 8
y = v/hx - b;
y + b = v/hx
=> x = ((y+b)/v)*h
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 2 ms 852 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 2 ms 852 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -