QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#762803#9600. Eat, Sleep, RepeatssxWA 7ms8180kbC++203.1kb2024-11-19 16:44:332024-11-19 16:44:33

Judging History

你现在查看的是最新测评结果

  • [2024-11-19 16:44:33]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:8180kb
  • [2024-11-19 16:44:33]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define pll pair<ll, ll>
#define ll long long
#define x first
#define y second
const int mod = 1e9 + 7;
const int N = 1e5 + 50;

vector<ll> e[N];
vector<pll> q;
pll pa[N];
ll n, k, a[N], res[N], sum[N], sum0[N], siz[N];
map<ll, ll> mp, mp1;

void check(ll x)
{
    if (x % 2 == 0) cout << "FuuFuu" << '\n';
    else cout << "Pico" << '\n'; 
    return ;
}

void solve()
{
    ll ok = 0, cnt;
    cin >> n >> k;
    mp.clear();
    mp1.clear();
    for (int i = 0; i <= k + 10; i++) 
    {
        e[i].clear();
        res[i] = 0;
        sum[i] = sum0[i] = 0;
        siz[i] = 0;
    }
    q.clear();

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        mp[a[i]] ++;
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) res[i] = res[i - 1] + a[i];
    for (int i = 1; i <= k; i++) 
    {
        cin >> pa[i].x >> pa[i].y;
        if (mp[pa[i].x] > pa[i].y) ok = 1;
        mp1[pa[i].x] = pa[i].y;
    }
    if (k == 0)
    {
        check(res[n]);
        return ;
    }
    if (ok == 1)
    {
        check(0);
        return ;
    }
    sort(pa + 1, pa + k + 1);
    vector<ll> v;
    ll l = 0, r = 0;
    for (int i = 1; i <= k; i++)
    {
        if (pa[i].y == 0) v.push_back(pa[i].x);
    }
    ll p = 0;
    cnt = 0;
    q.push_back({0, 0});

    if (v.size() == 0)
    {
        cnt ++;
        q.push_back({0, 1e18});
    }
    else
    {
        if (v[0] > 0)
        {
            cnt ++;
            q.push_back({0, v[0] - 1});
        }
        while (p < v.size() - 1)
        {
            while (p < v.size() - 1 && v[p + 1] == v[p] + 1) p ++;
            cnt ++;
            if (p == v.size() - 1) q.push_back({v[p] + 1, 1e18});
            else q.push_back({v[p] + 1, v[p + 1] - 1});
            p ++;
        }
        if (v.size() == 1)
        {
            cnt ++;
            q.push_back({v[0] + 1, 1e18});
        }
    }
    p = 1;
    for (int i = 1; i <= cnt; i++)
    {
        while (p <= n && a[p] >= q[i].x && a[p] <= q[i].y)
        {
            sum[i] += a[p];
            p ++;
            siz[i] ++;
        }
    }
    ll op = 0, va;
    for (int i = 1; i <= cnt; i++)
    {
        op = 0;
        for (int j = q[i].x; j <= q[i].y; j++)
        {
            if (mp1[j] == 0) va = 1e6;
            else va = mp1[j];
            if (va + op >= siz[i])
            {
                sum0[i] += j * (siz[i] - op);
                break;
            }
            else
            {
                sum0[i] += j * va;
                op += va;
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= cnt; i++)
    {
        if (sum[i] > 0) ans += sum[i] - sum0[i];
    }
    //cout << ans << '\n';
    check(ans);
    //for (int i = 1; i <= cnt; i++) cout << q[i].x << ' ' << q[i].y << '\n';
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll T = 1;
    cin >> T;
    while (T --)
    {
        solve();
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7672kb

input:

5
2 0
1 2
2 1
1 2
0 1
3 2
3 3 4
0 2
1 1
3 2
2 3 3
1 2
0 1
5 4
6 7 8 12 17
1 1
2 1
9 0
10 1

output:

Pico
FuuFuu
Pico
FuuFuu
Pico

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 8180kb

input:

10
1385 1384
914 1004 3060 1953 2517 745 879 849 3254 2069 3574 3705 2941 760 2522 3548 616 1328 1732 2420 2789 2448 3533 2058 308 3094 222 1960 3569 1463 2242 3258 1528 2779 1511 2855 1482 3304 2258 3525 3039 1489 3272 3295 1389 109 3370 2750 2207 1400 1570 888 422 646 3541 202 3384 2874 723 1157 3...

output:

Pico
FuuFuu
Pico
FuuFuu
Pico
Pico
FuuFuu
Pico
Pico
Pico

result:

wrong answer 2nd lines differ - expected: 'Pico', found: 'FuuFuu'