Submission #463434

# Submission time Handle Problem Language Result Execution time Memory
463434 2021-08-11T06:49:52 Z Em1L Fountain (eJOI20_fountain) C++14
30 / 100
209 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, q, x, y;
    
    cin >> n >> q;
    
    vector < vector <int> > cnt(n, vector <int>(n, 0));
    
    vector < pair <int, int> > v;
    
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        
        v.push_back({ x, y });
    }
    
    for (int i = 0; i < n; i++)
    {
        int prev = i, pos = 0;
        
        cnt[i][pos++] = i;
        
        for (int j = i; j < n; j++)
            if (v[prev].first < v[j].first)
            {
                cnt[i][pos++] = j;
                
                prev = j;
            }
            
        cnt[i].resize(pos);
    }
    
    for (int i = 0; i < q; i++)
    {
        cin >> x >> y;
        
        for (int i = 0; i < n; i++)
        {
            if (i > 0 and cnt[x - 1][i] == 0) break;
            
            y -= v[cnt[x - 1][i]].second;
            
            if (y <= 0)
            {
                cout << cnt[x - 1][i] + 1 << '\n';
                
                break;
            }
        }
        
        if (y > 0) cout << 0 << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 3 ms 1356 KB Output is correct
3 Correct 4 ms 2252 KB Output is correct
4 Correct 7 ms 4044 KB Output is correct
5 Correct 9 ms 4264 KB Output is correct
6 Correct 10 ms 4172 KB Output is correct
7 Correct 9 ms 4260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 209 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 3 ms 1356 KB Output is correct
3 Correct 4 ms 2252 KB Output is correct
4 Correct 7 ms 4044 KB Output is correct
5 Correct 9 ms 4264 KB Output is correct
6 Correct 10 ms 4172 KB Output is correct
7 Correct 9 ms 4260 KB Output is correct
8 Runtime error 209 ms 524292 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -