# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
882897 | Matjaz | Sails (IOI07_sails) | C++14 | 1099 ms | 4832 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//
// IOI2007Sails.cpp
//
//
// Created by Matjaz Leonardis on 04/12/2023.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int INF = 100001;
int main(){
int N;
cin >> N;
vector<int> H(N),K(N);
for (int i=0;i<N;i++) cin >> H[i] >> K[i];
vector<int> S(100001);
for (int i=N-1;i>=0;i--){
priority_queue<pair<int,int> > Q;
for (int j=1;j<=H[i];j++) Q.push(make_pair(-S[j], j));
for (int j=0;j<K[i];j++){
S[Q.top().second]++; Q.pop();
}
}
long long total=0;
for (int i=0;i<S.size();i++){
total += ((long long)S[i] * (S[i] - 1)) / 2;
}
cout << total << endl;
return 0;
}
Compilation message (stderr)
# | 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... |