답안 #463576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
463576 2021-08-11T10:31:39 Z Em1L Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 1488 KB
#include <bits/stdc++.h>
using namespace std;

#define fountain    pair<int,int>
#define len         first
#define vol         second

void fastIO()
{
    ios_base::sync_with_stdio(false);
    
    cin.tie(NULL);
    cout.tie(NULL);
}

int main()
{
    fastIO();
    
    int n, q, pos, lits;
    
    cin >> n >> q;
    
    vector <fountain> v(n);
    
    vector <int> next(n, -1);
    
    for (int i = 0; i < n; i++) cin >> v[i].len >> v[i].vol;
    
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            if (v[j].len > v[i].len)
            {
                next[i] = j;
                
                break;
            }
            
    for (int i = 0; i < q; i++)
    {
        cin >> pos >> lits; pos--;
        
        while (pos != -1)
        {
            lits -= v[pos].vol;
            
            if (lits <= 0)
            {
                cout << pos + 1 << '\n';
                
                break;
            }
            
            pos = next[pos];
        }
        
        if (lits > 0) cout << 0 << '\n';
    }
}
# 결과 실행 시간 메모리 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 332 KB Output is correct
5 Correct 3 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1590 ms 1488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 332 KB Output is correct
5 Correct 3 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Execution timed out 1590 ms 1488 KB Time limit exceeded
9 Halted 0 ms 0 KB -