답안 #463436

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
463436 2021-08-11T06:50:53 Z Eldar Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 1384 KB
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,q,d,c,r,v,total;
	vector<pair<int,int> > reservoir;
	cin>>n>>q;
	for(int i=0;i<n;i++){
        cin>>d>>c;
        reservoir.push_back(make_pair(d,c));
	}
	//works ^
	while(q--){
        cin>>r>>v;
        total=reservoir[r-1].second;
        for(int i=r-1;i<n;i=i){
            if(total>=v){
                cout<<i+1<<"\n";
                break;
            }
            else if(i+1==n){
                cout<<0<<"\n";
                break;
            }
            else{
                for(int j=i+1;j<n;j++){
                    if(reservoir[i].first>=reservoir[j].first&&j!=n-1)
                        continue;
                    else if(reservoir[i].first>=reservoir[j].first&&j==n-1){
                        cout<<0<<"\n";
                        i=n;
                        break;
                    }
                    else{
                        //cout<<j<<" j\n";
                        i=j;
                        total+=reservoir[i].second;
                        if(total>=v)
                            break;
                        //cout<<v<<" v\n";
                        //cout<<reservoir[i].second<<" reservoir[i].second\n";

                    }
                }
            }
        }
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
4 Correct 4 ms 204 KB Output is correct
5 Correct 7 ms 204 KB Output is correct
6 Correct 7 ms 204 KB Output is correct
7 Correct 5 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1587 ms 1384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
4 Correct 4 ms 204 KB Output is correct
5 Correct 7 ms 204 KB Output is correct
6 Correct 7 ms 204 KB Output is correct
7 Correct 5 ms 204 KB Output is correct
8 Execution timed out 1587 ms 1384 KB Time limit exceeded
9 Halted 0 ms 0 KB -