Submission #463431

# Submission time Handle Problem Language Result Execution time Memory
463431 2021-08-11T06:42:55 Z gavgav Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 1424 KB
#include <iostream>
#include <stack>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    uint32_t N, Q, level, volume;
    cin >> N >> Q;
    uint32_t diametrs[N], ng[N] {};
    uint16_t capacitys[N];
    stack <uint32_t> meowmeow;
    for (uint32_t i = 0; i < N; i++){
        cin >> diametrs[i] >> capacitys[i];
        while (!meowmeow.empty() && diametrs[meowmeow.top()] < diametrs[i]){
                ng[meowmeow.top()] = i;
                meowmeow.pop();
        }
        meowmeow.push(i);
    }
    for (uint32_t i = 0; i < Q; i++){
        cin >> level >> volume;
        level--;
        do{
            if (volume < capacitys[level] + 1){
                level++;
                break;
            }
            volume -= capacitys[level];
            level = ng[level];
        } while (level);
        cout << level << '\n';
    }
}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:24:24: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Wsign-compare]
   24 |             if (volume < capacitys[level] + 1){
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 3 ms 204 KB Output is correct
6 Correct 2 ms 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1575 ms 1424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 3 ms 204 KB Output is correct
6 Correct 2 ms 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Execution timed out 1575 ms 1424 KB Time limit exceeded
9 Halted 0 ms 0 KB -