답안 #878461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878461 2023-11-24T12:17:01 Z AndreasK Fountain (eJOI20_fountain) C++14
0 / 100
1500 ms 3376 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,Q;
cin>>N>>Q;
int c;
pair <int,int> A[N];//diameter capacity
int ps[N];
for (c=0;c<N;c++){
    cin>>A[c].first>>A[c].second;
    if (c==0)
        ps[c]=A[c].second;
    else
        ps[c]=ps[c-1]+A[c].second;
}
while (Q--){
    int where,how_many;
    cin>>where>>how_many;
    where--;int mx=0;
    int start=where;
    int stop=N-1;
    while (start<stop){
        int mid=(start+stop)/2;
        if (ps[mid]<how_many)
            start++;
        else
            stop--;
    }
    if (start!=N+1)
    cout<<start<<'\n';
    else
    cout<<0<<'\n';
}
return 0;}

Compilation message

fountain.cpp: In function 'int main()':
fountain.cpp:19:17: warning: unused variable 'mx' [-Wunused-variable]
   19 |     where--;int mx=0;
      |                 ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1536 ms 3376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -