답안 #576443

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576443 2022-06-13T06:13:49 Z vqpahmad Fountain (eJOI20_fountain) C++14
0 / 100
55 ms 2372 KB
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define all(a) a.begin(),a.end()
#define mod (ll)(10000007)
using namespace std;
const int mx = 1e6 + 15;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,q;
    cin >> n >> q;
    vector<pair<int,int>> a(n);//fist diamter , second is water
    for (int i=0;i<n;i++){
        cin >> a[i].first >> a[i].second;
    }
    if (n<=1000&&q<=2000){
        while (q--){
            int d,v;
            cin >> d >> v;
            d--;
            int mx=a[d].first;
            int cnt = 0;
            v-=a[d].second;
            if (v>=0) cnt++;
            d++;
            while(d<n&&v>0){
                if (a[d].first > mx){
                    v-=a[d].second;
                    if (v>=0) cnt++;
                }
                d++;
            }
            d<n?cout << d << endl:cout << 0 << endl;
        }
    }
    else {
        vector<ll> pref(n+1);
        for (int i=1;i<=n;i++){
            pref[i] = pref[i-1]+a[i-1].first;
        }
        while (q--){
            int d,v;
            cin >> d >> v;
            ll num = pref[d];
            int up = upper_bound(all(pref),num+v)-pref.begin();
            up < n ? cout << up <<endl : cout << 0 << endl;
        }

    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 2372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -