Submission #73904477
Source Code Expand
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
// M = 1,2,..
// Grams(j) = 1<= j <= M.size
// orders N dishes
// if dish i, A(i) pepper = true, else false
// Max amount = B. : A < B
// Total Pepper (j) < C(j) grams
// Goal: total pepper sprinkle possible
int main() {
int n, m;
if (!(cin >> n >> m)) return 0;
vector<long long> c(m + 1);
for (int j = 1; j <= m; j++) {
cin >> c[j];
}
// sum b_i for each pepper type a_i
vector<long long> demand(m + 1, 0);
for (int i = 0; i < n; i++) {
int a;
long long b;
cin >> a >> b;
// Group dish i's limit into its required pepper type a_i
demand[a] += b;
}
long long total_sprinkled = 0;
for (int j = 1; j <= m; j++) {
//can only use as much as have (C) or as much as is allowed (demand)
total_sprinkled += min(c[j], demand[j]);
}
cout << total_sprinkled << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Pepper Addiction |
| User | Monaco37 |
| Language | C++23 (GCC 15.2.0) |
| Score | 200 |
| Code Size | 1020 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3640 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample_01.txt | AC | 1 ms | 3620 KiB |
| sample_02.txt | AC | 1 ms | 3640 KiB |
| sample_03.txt | AC | 1 ms | 3532 KiB |
| test_01.txt | AC | 1 ms | 3640 KiB |
| test_02.txt | AC | 1 ms | 3484 KiB |
| test_03.txt | AC | 1 ms | 3416 KiB |
| test_04.txt | AC | 1 ms | 3532 KiB |
| test_05.txt | AC | 1 ms | 3484 KiB |
| test_06.txt | AC | 1 ms | 3484 KiB |
| test_07.txt | AC | 1 ms | 3640 KiB |
| test_08.txt | AC | 1 ms | 3620 KiB |
| test_09.txt | AC | 1 ms | 3608 KiB |
| test_10.txt | AC | 1 ms | 3604 KiB |
| test_11.txt | AC | 1 ms | 3540 KiB |
| test_12.txt | AC | 1 ms | 3492 KiB |
| test_13.txt | AC | 1 ms | 3440 KiB |
| test_14.txt | AC | 1 ms | 3604 KiB |
| test_15.txt | AC | 1 ms | 3492 KiB |
| test_16.txt | AC | 1 ms | 3532 KiB |
| test_17.txt | AC | 1 ms | 3476 KiB |