Submission #159106


Source Code Expand

Copy
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
int main( void )
{
  int K,N;
  priority_queue< P,vector<P>,greater<P> > q;
  cin >> K >> N;
  for( int i=0; i<N; i++ ){
    ll a; int b;
    cin >> a >> b;
    q.push( P(a,b) );
  }
  ll ret=0;
  for( int i=0; i<K; i++ ){
    ll a = q.top().first;
    int b = q.top().second;
    ret += a;
    q.pop();
    q.push( P(a+b,b) );
  }
  cout << ret << endl;
  return 0;
}

Submission Info

Submission Time
Task C - 増築王高橋君
User capythm
Language C++ (G++ 4.6.4)
Score 55
Code Size 497 Byte
Status
Exec Time 2032 ms
Memory 2980 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 15 / 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 21 ms 676 KB
subtask0_sample-02.txt 21 ms 928 KB
subtask1_01.txt 21 ms 796 KB
subtask1_02.txt 21 ms 800 KB
subtask1_03.txt 21 ms 932 KB
subtask1_04.txt 20 ms 804 KB
subtask1_05.txt 20 ms 844 KB
subtask1_06.txt 20 ms 800 KB
subtask1_07.txt 20 ms 804 KB
subtask1_08.txt 21 ms 800 KB
subtask1_09.txt 21 ms 740 KB
subtask1_10.txt 21 ms 800 KB
subtask1_11.txt 20 ms 928 KB
subtask1_12.txt 21 ms 932 KB
subtask2_01.txt 21 ms 764 KB
subtask2_02.txt 22 ms 920 KB
subtask2_03.txt 22 ms 928 KB
subtask2_04.txt 21 ms 800 KB
subtask2_05.txt 23 ms 928 KB
subtask2_06.txt 26 ms 940 KB
subtask2_07.txt 23 ms 924 KB
subtask2_08.txt 24 ms 920 KB
subtask2_09.txt 25 ms 924 KB
subtask2_10.txt 26 ms 984 KB
subtask2_11.txt 26 ms 1056 KB
subtask2_12.txt 26 ms 984 KB
subtask3_01.txt 22 ms 924 KB
subtask3_02.txt 24 ms 808 KB
subtask3_03.txt 24 ms 920 KB
subtask3_04.txt 105 ms 2968 KB
subtask3_05.txt 26 ms 1012 KB
subtask3_06.txt 40 ms 804 KB
subtask3_07.txt 48 ms 1444 KB
subtask3_08.txt 109 ms 2968 KB
subtask3_09.txt 127 ms 2972 KB
subtask3_10.txt 117 ms 2972 KB
subtask3_11.txt 127 ms 2980 KB
subtask3_12.txt 75 ms 1948 KB
subtask4_01.txt 121 ms 2968 KB
subtask4_02.txt 2029 ms 804 KB
subtask4_03.txt 2028 ms 932 KB
subtask4_04.txt 587 ms 2972 KB
subtask4_05.txt 2030 ms 932 KB
subtask4_06.txt 109 ms 848 KB
subtask4_07.txt 2030 ms 804 KB
subtask4_08.txt 67 ms 796 KB
subtask4_09.txt 2030 ms 2972 KB
subtask4_10.txt 2029 ms 940 KB
subtask4_11.txt 2029 ms 2964 KB
subtask4_12.txt 2032 ms 2972 KB
subtask4_13.txt 2029 ms 2972 KB
subtask4_14.txt 2029 ms 800 KB