QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770132#9600. Eat, Sleep, Repeatyeah14WA 1ms3756kbC++172.4kb2024-11-21 20:48:172024-11-21 20:48:18

Judging History

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

  • [2024-11-21 20:48:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3756kb
  • [2024-11-21 20:48:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull long long
#define PII  pair<int ,int>
const int INF = 1145141919810;
const int mod = 1e9 + 7;
int fp(int a, int x, int mod) {
    int ans = 1;
    while (x) {
        if (x & 1)ans *= a;
        ans %= mod;
        a *= a;
        a %= mod;
        x >>= 1;
    }
    return ans;
}

const int N = 1e5+5;
map<int, int>p;
int a[N];
vector<PII> xy;
vector<PII> x_y;
void solve1() {
    int n, k;
    cin >> n >> k;
    p.clear();
    xy.clear();
    x_y.clear();
    priority_queue<int,vector<int>,greater<int>>q;//分界
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        p[a[i]]++;
    }
    int minn = 0;
    int sum = minn;
    q.push(-1);
    q.push(INF);
    //if (k == 0)xy.push_back({ 0,INF });
    for (int i = 1; i <= k; i++) {
        int x, y;
        cin >> x >> y;
        x_y.push_back({ x,y });
    }
    sort(x_y.begin(), x_y.end());
    for (int i = 0; i < k; i++) {
        int x = x_y[i].first;
        int y = x_y[i].second;
        if (y == 0) {
            q.push(x);
            xy.push_back({ minn,INF });
            minn = x + 1;
            continue;
        }
        if (minn == x) {
            xy.push_back({ x,y });
            minn++;
        }
    }
    xy.push_back({ minn,INF });
    sort(xy.begin(), xy.end());
    auto pp=p.begin();
    int j = 0;
    int ans = 0;
    while (!q.empty()&&pp!=p.end()) {
        q.pop();
        int t = q.top();
        int cnt1 = 0;
        int sum = 0;
        while (pp!=p.end()&&(*pp).first <= t) {
            sum+=(*pp).second*(*pp).first;
            cnt1 += (*pp).second;
            pp++;
            
        }
        int cnt = 0;
        int sum2 = 0;
        while (cnt < cnt1&&j<xy.size() && xy[j].first < t) {
            int cc = min(xy[j].second, cnt1 - cnt);
            cnt += cc;
            sum2 += cc * xy[j].first;
            j++;
        }
        ans += max(sum - sum2,0LL);
        while (j<xy.size()&&xy[j].first <= t) {
            j++;
        }
    }
    cout << ans << endl;
    if (ans % 2 == 0)cout << "FuuFuu" << endl;
    else cout << "Pico" << endl;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t=1;
    cin >> t;
    while (t--) {
        solve1();
    }
}
/*
1
5 4
1 2 3 4 5
0 1
1 1
2 1
3 0
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3756kb

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:

3
Pico
2
FuuFuu
9
Pico
6
FuuFuu
29
Pico

result:

wrong answer 1st lines differ - expected: 'Pico', found: '3'