Submission #73887751
Source Code Expand
#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); ++i)
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
int gcd(int a, int b){
if(b == 0) return a;
else return gcd(b, a%b);
}
struct Compare {
bool operator()(const pair<ll, int>& a, const pair<ll, int>& b) {
return a.first > b.first;
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m; cin >> n >> m;
vector<ll> c(m);
rep(i,m) cin >> c[i];
vector<int> a(n);
vector<ll> b(n);
rep(i,n){
cin >> a[i] >> b[i];
a[i]--;
}
ll ans = 0;
rep(i,n){
ans += min(c[a[i]], b[i]);
c[a[i]] -= b[i];
chmax(c[a[i]], 0LL);
}
cout << ans << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Pepper Addiction |
| User | motomoto0001 |
| Language | C++23 (GCC 15.2.0) |
| Score | 200 |
| Code Size | 1039 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3748 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 | 3440 KiB |
| sample_02.txt | AC | 1 ms | 3576 KiB |
| sample_03.txt | AC | 1 ms | 3532 KiB |
| test_01.txt | AC | 1 ms | 3424 KiB |
| test_02.txt | AC | 1 ms | 3408 KiB |
| test_03.txt | AC | 1 ms | 3612 KiB |
| test_04.txt | AC | 1 ms | 3632 KiB |
| test_05.txt | AC | 1 ms | 3540 KiB |
| test_06.txt | AC | 1 ms | 3708 KiB |
| test_07.txt | AC | 1 ms | 3636 KiB |
| test_08.txt | AC | 1 ms | 3680 KiB |
| test_09.txt | AC | 1 ms | 3748 KiB |
| test_10.txt | AC | 1 ms | 3680 KiB |
| test_11.txt | AC | 1 ms | 3704 KiB |
| test_12.txt | AC | 1 ms | 3748 KiB |
| test_13.txt | AC | 1 ms | 3704 KiB |
| test_14.txt | AC | 1 ms | 3664 KiB |
| test_15.txt | AC | 1 ms | 3508 KiB |
| test_16.txt | AC | 1 ms | 3748 KiB |
| test_17.txt | AC | 1 ms | 3536 KiB |