QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572535#3937. FishmongersLaVuna47#AC ✓24ms5652kbC++172.0kb2024-09-18 15:11:352024-09-18 15:11:35

Judging History

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

  • [2024-09-18 15:11:35]
  • 评测
  • 测评结果:AC
  • 用时:24ms
  • 内存:5652kb
  • [2024-09-18 15:11:35]
  • 提交

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define RFOR(i, n) for(int i = n-1; i >= 0; --i)
#define output_vec(vec) { FOR(i_, sz(vec)) cout << vec[i_] << ' '; cout << '\n'; }
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<bool> vb;
typedef short si;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif


int solve()
{
    int n, m;
    if(!(cin >> n >> m))
        return 1;
    vector<ll> w(n);
    FOR(i, n) cin >> w[i];
    vector<pll> cp(m);
    FOR(i, m) cin >> cp[i].x >> cp[i].y;
    sort(rall(w));
    sort(all(cp), [](pll e1, pll e2) -> bool {
        return e1.y > e2.y;
    });
    ll res = 0;
    for(int i = 0, j = 0; i < n && j < m; ++i)
    {
        res += w[i] * cp[j].y;
        cp[j].x -= 1;
        if(cp[j].x == 0)
            ++j;
    }
    cout << res << '\n';
    return 0;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1e9;
    //cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

4 3
1 2 7 5
2 4
1 5
3 3

output:

66

result:

ok single line: '66'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

10 10
7 7 1 5 9 8 7 5 8 6
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
10 2

output:

126

result:

ok single line: '126'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

10 1
3 10 2 5 2 8 8 8 7 4
1 1

output:

10

result:

ok single line: '10'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

10 10
1 2 2 6 3 5 5 10 4 10
1 76180
2 56449
4 94767
5 48767
5 58308
5 35159
1 3598
3 60935
3 49810
4 68912

output:

4137644

result:

ok single line: '4137644'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

10 10
4 10 9 3 6 10 8 10 2 10
1 61504
3 72193
2 25133
4 70907
5 62437
4 83764
2 30399
2 68575
4 97158
1 88004

output:

6581786

result:

ok single line: '6581786'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

10 10
4 5 2 7 8 3 2 2 1 7
5 37930
1 29089
5 70344
3 36266
2 13918
3 28102
1 83977
3 35619
2 21604
3 37964

output:

2766474

result:

ok single line: '2766474'

Test #7:

score: 0
Accepted
time: 21ms
memory: 5528kb

input:

100000 100000
81645 33482 97228 46994 90499 96980 85464 69474 3802 61031 32644 85063 6797 20559 14839 48732 61482 32319 49907 71272 13366 75228 32681 1719 95838 28408 53498 36633 23866 51045 20920 99868 9429 18189 80993 80931 58306 16607 17334 233 697 27454 28244 21740 21822 37920 41111 26069 70678 ...

output:

443803797190289

result:

ok single line: '443803797190289'

Test #8:

score: 0
Accepted
time: 21ms
memory: 5652kb

input:

100000 100000
75212 10561 63575 99906 34292 4827 60 19082 86877 76872 61638 99580 96317 48911 41863 2870 35744 64074 25967 95660 54265 70557 70681 89398 12349 25295 73849 72564 91688 95537 34803 86888 79961 89875 11549 55667 43986 12208 47467 53733 32832 58355 91701 12292 99034 25843 91849 83221 381...

output:

443536004360304

result:

ok single line: '443536004360304'

Test #9:

score: 0
Accepted
time: 21ms
memory: 5528kb

input:

100000 100000
42446 19773 51751 85320 6329 9495 70240 12338 47932 76388 7603 66511 28141 4915 11266 56839 54811 9157 31545 11890 72227 55643 7748 74116 16227 29261 82658 82239 76415 8109 75643 76749 51994 6500 28978 6106 72964 17456 37960 54938 18908 70869 15440 74831 40434 73435 89392 23689 13508 7...

output:

444310755559219

result:

ok single line: '444310755559219'

Test #10:

score: 0
Accepted
time: 24ms
memory: 5560kb

input:

100000 100000
29715 48551 49201 16559 25313 92382 5739 11166 17937 32433 66370 27447 52522 84131 3971 60180 63885 59393 51181 64879 75121 25197 52781 11740 63583 30695 99487 2621 91903 34966 68181 53434 62171 49687 95159 14907 86896 33864 12736 8270 50643 81287 49442 14121 86619 7610 44360 30726 906...

output:

444138050036794

result:

ok single line: '444138050036794'

Test #11:

score: 0
Accepted
time: 17ms
memory: 5492kb

input:

100000 100000
100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000...

output:

1000000000000000

result:

ok single line: '1000000000000000'