Submission #463430

# Submission time Handle Problem Language Result Execution time Memory
463430 2021-08-11T06:39:27 Z gavgav Fountain (eJOI20_fountain) C++17
30 / 100
1500 ms 1300 KB
#include <iostream>
#include <stack>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    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 << endl;
    }
}

Compilation message

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