This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> h(n + 1);
vector<int> c(n + 1);
for(int i = 1; i <= n; i++) {
int u, v;
cin >> u >> v;
h[n - i + 1] = u;
c[n - i + 1] = v;
}
int ans = 0;
vector<int> M(n + 1, 0);
for(int i = 1; i <= n; i++) {
int br = 0;
vector<int> mark(h[i] + 1, 0);
while(c[i]--) {
br += 1;
//cout << "za :::" << i << "za" << br << " jedro stavljam na :::";
int mn = n + 1;
for(int j = h[i]; j >= 1; j--) {
if(mark[j]) {
continue;
}
mn = min(mn, M[j]);
}
ans += mn;
//cout << "stub ::: " << i << " za " << br << "jedro resenje min je::: {" << mn;
for(int j = h[i]; j >= 1; j--) {
if(mark[j]) {
continue;
}
if(M[j] == mn) {
M[j] += 1;
mark[j] = 1;
//cout << " " << j << "} \n";
break;
}
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |