Submission #463449

# Submission time Handle Problem Language Result Execution time Memory
463449 2021-08-11T07:28:21 Z Em1L Fountain (eJOI20_fountain) C++14
30 / 100
1094 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n, q, x, y;
    
    cin >> n >> q;
    
    vector < vector <int> > cnt;
    
    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;
        
        cnt.push_back(vector <int>());
        
        cnt[i].push_back(i);
        
        for (int j = i; j < n; j++)
            if (v[prev].first < v[j].first)
            {
                cnt[i].push_back(j);
                
                prev = j;
            }
    }
    
    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 2 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 6 ms 304 KB Output is correct
5 Correct 11 ms 2892 KB Output is correct
6 Correct 9 ms 1228 KB Output is correct
7 Correct 7 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1094 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 2 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 6 ms 304 KB Output is correct
5 Correct 11 ms 2892 KB Output is correct
6 Correct 9 ms 1228 KB Output is correct
7 Correct 7 ms 332 KB Output is correct
8 Runtime error 1094 ms 524292 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -