编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#57641 #1295. 汰换合同 Accepted 100 873 ms 7984 K C++ 17 / 1.8 K 丁丁跑卡车 2021-07-12 23:01:43
显示原始代码
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ud unsigned int
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
//#define pi 3.141592653589
#define eps 1e-9
#define F(x) ((x) / 3 + ((x) % 3 == 1 ? 0 : tb))
#define G(x) ((x) < tb ? (x)*3 + 1 : ((x)-tb) * 3 + 2)
//#define p 2173412051LL
//#define sz 2

using namespace std;

template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-')
            f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct p {
    int v, x;
    bool operator<(const p &o) const {
        if (v == o.v)
            return x > o.x;
        return v > o.v;
    }
};
priority_queue<p, vector<p> > q;
map<int, int> mp;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n;
    int x;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        q.push({ x, i });
    }
    int pv = -1, px;
    while (!q.empty()) {
        auto [v, x] = q.top();
        q.pop();
        if (v == pv) {
            q.push({ v << 1, x });
            pv = -1;
        } else {
            if (pv > 0)
                mp[px] = pv;
            pv = v;
            px = x;
        }
    }
    if (pv > 0)
        mp[px] = pv;
    cout << mp.size() << '\n';
    for (auto [x, v] : mp) cout << v << ' ';
    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:11 ms
内存:660 KiB

输入文件(1.in

8642
175519894 562746268 400905663 426546285 951806330 31203311 737272887 163393552 439949340 95090
<85309 bytes omitted>

答案文件(1.ans

8642
175519894 562746268 400905663 426546285 951806330 31203311 737272887 163393552 439949340 95090
<85309 bytes omitted>

用户输出

8642
175519894 562746268 400905663 426546285 951806330 31203311 737272887 163393552 439949340 950906646 791833232 145702547 3548
<85279 bytes omitted>

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:21 ms
内存:1468 KiB

输入文件(2.in

29067
128294881 390646925 542009547 411468317 59259372 193198579 113164642 886900047 478132078 2883
<287309 bytes omitted>

答案文件(2.ans

29067
128294881 390646925 542009547 411468317 59259372 193198579 113164642 886900047 478132078 2883
<287309 bytes omitted>

用户输出

29067
128294881 390646925 542009547 411468317 59259372 193198579 113164642 886900047 478132078 288344815 261220996 885661762 102
<287279 bytes omitted>

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:189 ms
内存:7984 KiB

输入文件(3.in

190613
18371619 908045473 819059066 265596072 694623020 519686091 43405805 372630198 706589497 4272
<1884764 bytes omitted>

答案文件(3.ans

190589
18371619 908045473 819059066 265596072 694623020 519686091 43405805 372630198 706589497 4272
<1884544 bytes omitted>

用户输出

190589
18371619 908045473 819059066 265596072 694623020 519686091 43405805 372630198 706589497 427257752 98501110 501486281 9647
<1884514 bytes omitted>

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:73 ms
内存:4048 KiB

输入文件(4.in

93123
94765784 675273792 380198265 233421872 372355922 336993268 94733189 637916743 188042328 21632
<920730 bytes omitted>

答案文件(4.ans

93115
94765784 675273792 380198265 233421872 372355922 336993268 94733189 637916743 188042328 21632
<920657 bytes omitted>

用户输出

93115
94765784 675273792 380198265 233421872 372355922 336993268 94733189 637916743 188042328 216323214 838583826 866151215 8068
<920627 bytes omitted>

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:72 ms
内存:4048 KiB

输入文件(5.in

92941
202103604 694621289 522085991 132401733 478129416 399183567 22196825 935358205 564663505 2685
<919104 bytes omitted>

答案文件(5.ans

92934
202103604 694621289 522085991 132401733 478129416 399183567 22196825 935358205 564663505 2685
<919037 bytes omitted>

用户输出

92934
202103604 694621289 522085991 132401733 478129416 399183567 22196825 935358205 564663505 268518316 488930197 821583709 512
<919007 bytes omitted>

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:48 ms
内存:2780 KiB

输入文件(6.in

59899
993621348 738656373 720681223 713507 724283228 297785884 844532258 290737446 536030742 840604
<592298 bytes omitted>

答案文件(6.ans

59897
993621348 738656373 720681223 713507 724283228 297785884 844532258 290737446 536030742 840604
<592280 bytes omitted>

用户输出

59897
993621348 738656373 720681223 713507 724283228 297785884 844532258 290737446 536030742 84060411 887785124 386758743 533450
<592250 bytes omitted>

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:183 ms
内存:7856 KiB

输入文件(7.in

188137
629950745 178253015 805718054 508239800 882909898 900045356 755490080 635799484 880554528 69
<1860439 bytes omitted>

答案文件(7.ans

188117
629950745 178253015 805718054 508239800 882909898 900045356 755490080 635799484 880554528 69
<1860249 bytes omitted>

用户输出

188117
629950745 178253015 805718054 508239800 882909898 900045356 755490080 635799484 880554528 69704944 999214328 826004436 64
<1860219 bytes omitted>

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:10 ms
内存:884 KiB

输入文件(8.in

10033
658479189 936438762 827405007 18675350 30142649 469457010 957101746 1653463 704338286 6612265
<99117 bytes omitted>

答案文件(8.ans

10033
658479189 936438762 827405007 18675350 30142649 469457010 957101746 1653463 704338286 6612265
<99117 bytes omitted>

用户输出

10033
658479189 936438762 827405007 18675350 30142649 469457010 957101746 1653463 704338286 661226551 870780104 784564763 318996
<99087 bytes omitted>

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:145 ms
内存:6400 KiB

输入文件(9.in

149626
453654618 756450959 623633819 444867847 512562076 984968382 734324497 802428195 664643465 70
<1479492 bytes omitted>

答案文件(9.ans

149619
453654618 756450959 623633819 444867847 512562076 984968382 734324497 802428195 664643465 70
<1479424 bytes omitted>

用户输出

149619
453654618 756450959 623633819 444867847 512562076 984968382 734324497 802428195 664643465 707622424 234762761 470522080 5
<1479394 bytes omitted>

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:121 ms
内存:5444 KiB

输入文件(10.in

129228
488641303 102158879 683410399 591156157 973480440 910056283 489501124 48484657 940480271 181
<1278033 bytes omitted>

答案文件(10.ans

129217
488641303 102158879 683410399 591156157 973480440 910056283 489501124 48484657 940480271 181
<1277930 bytes omitted>

用户输出

129217
488641303 102158879 683410399 591156157 973480440 910056283 489501124 48484657 940480271 181617093 390703077 171218104 25
<1277900 bytes omitted>

系统信息

Exited with return code 0