Submission #159176


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)

int main()
{
    int k, n;
    cin >> k >> n;

    vector<PII> ad;
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        ad.push_back(PII(a, b));
    }
    partial_sort(ad.begin(), ad.begin() + 1, ad.end());

    LL ans = 0;

    REP(i, k) {
        ans += ad[0].first;
        ad[0].first += ad[0].second;
        partial_sort(ad.begin(), ad.begin() + 1, ad.end());
    }

    cout << ans << endl;
}

Submission Info

Submission Time
Task C - 増築王高橋君
User awaki75
Language C++ (G++ 4.6.4)
Score 40
Code Size 683 Byte
Status
Exec Time 2033 ms
Memory 1956 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_sample-01.txt, subtask0_sample-02.txt
Subtask1 30 / 30 subtask0_sample-01.txt, subtask0_sample-02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt
Subtask2 10 / 10 subtask0_sample-01.txt, subtask0_sample-02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Subtask3 0 / 15 subtask0_sample-01.txt, subtask0_sample-02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt
Subtask4 0 / 45 subtask0_sample-01.txt, subtask0_sample-02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt, subtask4_01.txt, subtask4_02.txt, subtask4_03.txt, subtask4_04.txt, subtask4_05.txt, subtask4_06.txt, subtask4_07.txt, subtask4_08.txt, subtask4_09.txt, subtask4_10.txt, subtask4_11.txt, subtask4_12.txt, subtask4_13.txt, subtask4_14.txt
Case Name Status Exec Time Memory
subtask0_sample-01.txt 23 ms 772 KB
subtask0_sample-02.txt 21 ms 924 KB
subtask1_01.txt 21 ms 928 KB
subtask1_02.txt 21 ms 932 KB
subtask1_03.txt 21 ms 804 KB
subtask1_04.txt 21 ms 924 KB
subtask1_05.txt 21 ms 756 KB
subtask1_06.txt 21 ms 804 KB
subtask1_07.txt 21 ms 800 KB
subtask1_08.txt 21 ms 932 KB
subtask1_09.txt 21 ms 924 KB
subtask1_10.txt 22 ms 756 KB
subtask1_11.txt 21 ms 932 KB
subtask1_12.txt 21 ms 676 KB
subtask2_01.txt 21 ms 804 KB
subtask2_02.txt 25 ms 804 KB
subtask2_03.txt 24 ms 928 KB
subtask2_04.txt 21 ms 792 KB
subtask2_05.txt 25 ms 808 KB
subtask2_06.txt 79 ms 928 KB
subtask2_07.txt 91 ms 820 KB
subtask2_08.txt 78 ms 804 KB
subtask2_09.txt 108 ms 808 KB
subtask2_10.txt 142 ms 924 KB
subtask2_11.txt 135 ms 928 KB
subtask2_12.txt 54 ms 928 KB
subtask3_01.txt 22 ms 932 KB
subtask3_02.txt 21 ms 920 KB
subtask3_03.txt 86 ms 932 KB
subtask3_04.txt 125 ms 1944 KB
subtask3_05.txt 24 ms 924 KB
subtask3_06.txt 1328 ms 932 KB
subtask3_07.txt 2030 ms 1136 KB
subtask3_08.txt 2029 ms 1952 KB
subtask3_09.txt 2029 ms 1900 KB
subtask3_10.txt 2029 ms 1952 KB
subtask3_11.txt 2029 ms 1940 KB
subtask3_12.txt 2029 ms 1368 KB
subtask4_01.txt 2029 ms 1956 KB
subtask4_02.txt 2029 ms 808 KB
subtask4_03.txt 2029 ms 916 KB
subtask4_04.txt 2033 ms 1880 KB
subtask4_05.txt 2029 ms 932 KB
subtask4_06.txt 205 ms 812 KB
subtask4_07.txt 632 ms 916 KB
subtask4_08.txt 66 ms 812 KB
subtask4_09.txt 2029 ms 1948 KB
subtask4_10.txt 2030 ms 864 KB
subtask4_11.txt 2030 ms 1944 KB
subtask4_12.txt 2029 ms 1948 KB
subtask4_13.txt 2029 ms 1952 KB
subtask4_14.txt 632 ms 676 KB