답안 #463376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
463376 2021-08-11T04:19:53 Z Eldar Fountain (eJOI20_fountain) C++14
30 / 100
1500 ms 1340 KB
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,q,d,c,r,v;
	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;
        for(int i=r-1;i<n;i=i){
            if(reservoir[i].second>=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";
                        v-=reservoir[i].second;
                        i=j;
                        //cout<<v<<" v\n";
                        //cout<<reservoir[i].second<<" reservoir[i].second\n";
                        break;
                    }
                }
            }
        }
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 5 ms 204 KB Output is correct
5 Correct 9 ms 204 KB Output is correct
6 Correct 9 ms 308 KB Output is correct
7 Correct 6 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1582 ms 1340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 5 ms 204 KB Output is correct
5 Correct 9 ms 204 KB Output is correct
6 Correct 9 ms 308 KB Output is correct
7 Correct 6 ms 204 KB Output is correct
8 Execution timed out 1582 ms 1340 KB Time limit exceeded
9 Halted 0 ms 0 KB -