Submission #624965

# Submission time Handle Problem Language Result Execution time Memory
624965 2022-08-09T08:21:07 Z Stavab Sails (IOI07_sails) C++14
15 / 100
1000 ms 1904 KB
#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();
    }
    
    cout << sum << "\n";
    
    return 0;
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
sails.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%d %d", &h, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1012 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 1108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 1236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 1536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 1620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 1748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 1904 KB Time limit exceeded
2 Halted 0 ms 0 KB -