# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624962 | Stavab | Sails (IOI07_sails) | C++14 | 1090 ms | 3024 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.
#include <iostream>
#include <vector>
#include <stack>
#include <utility>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
vector<int> rows(100005, 0);
int h, k;
stack<pair<int, int>> input;
while(n--)
{
scanf("%d %d", &h, &k);
input.push(make_pair(h, k));
}
long long sum = 0;
vector<int> put(100005);
while(!input.empty())
{
int toFill = input.top().second;
int height = input.top().first;
for(int i = 1; i <= height; i++)
put[i] = 0;
for(int i = 0; i <= 100005; i++)
{
for(int j = height; j > 0; j--)
{
if(!put[j] && rows[j] == i)
{
sum += rows[j];
put[j] = 1;
rows[j]++;
toFill--;
}
if(!toFill)
break;
}
if(!toFill)
break;
}
input.pop();
}
printf("%lld\n", sum);
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... |