Submission #4519066


Source Code Expand

Copy
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <map>
#define MOD (1000000007l)

using namespace std;

int main(void) {
  long N, M;
  cin >> N >> M;
  vector<long> A, B;
  for (long i = 0; i < N; i++) {
    long a, b;
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }
  map<long, long> m;
  for (long i = 0; i < N; i++) {
    m[A[i]] = i;
  }
  long result = 0;
  long current = 0;
  for (auto it: m) {
    if (B[it.second] >= M - current) {
      result += it.first * (M - current);
      current = M;
      break;
    } else {
      result += it.first * B[it.second];
      current += B[it.second];
    }
  }
  cout << result << endl;
  return 0;
}

Submission Info

Submission Time
Task C - Energy Drink Collector
User set0gut1
Language C++14 (GCC 5.4.1)
Score 0
Code Size 742 Byte
Status
Exec Time 103 ms
Memory 8044 KB

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 300 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 2 ms 256 KB
sample_02 2 ms 256 KB
sample_03 2 ms 256 KB
testcase_01 61 ms 4980 KB
testcase_02 103 ms 8044 KB
testcase_03 85 ms 7404 KB
testcase_04 17 ms 1276 KB
testcase_05 34 ms 2036 KB
testcase_06 30 ms 2932 KB
testcase_07 93 ms 8044 KB
testcase_08 92 ms 8044 KB
testcase_09 44 ms 3700 KB
testcase_10 93 ms 8044 KB
testcase_11 2 ms 256 KB
testcase_12 95 ms 8044 KB
testcase_13 28 ms 2684 KB
testcase_14 61 ms 2036 KB
testcase_15 76 ms 2036 KB
testcase_16 33 ms 3188 KB