11991 - Easy Problem from Rujia Liu?

All about problems in Volume 119. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11991 - Easy Problem from Rujia Liu?

Post by brianfry713 » Tue Jan 27, 2015 1:04 am

Don't use a package, use class Main.
Check input and AC output for thousands of problems on uDebug!

tonmoy64
New poster
Posts: 1
Joined: Sat Aug 29, 2015 7:50 am

Re: 11991 - Easy Problem from Rujia Liu?

Post by tonmoy64 » Sat Aug 29, 2015 8:04 am

why i get RTE ???? :(

Code: Select all

#include<iostream>
#include<vector>
#include<iterator>
using namespace std;
vector<int>vi[100050];
vector<int>::iterator it;
int main()
{
    
    int i,j,m,n,u,v,a;
    while(cin>>m>>n)
    {
        for(i=1;i<=m;i++)
        {
            cin>>a;
            vi[a].push_back(i);
        }
        
        for(j=1;j<=n;j++)
        {
            cin>>u>>v;
            it=vi[v].begin();
            if(u>vi[v].size())
            {
                cout<<0<<endl;
            }
            
            else{
                    int k=1;
                    while(it!=vi[v].end()){
                        if(k==u){
                        cout<<*it<<endl;
                        break;
                        }
                        it++;
                        k++;
                        }
                        k=0;
                }
    }
    
    for(int l=0;l<=100000;l++)
        vi[l].clear();

    }
    return 0;
}

bitaron
New poster
Posts: 12
Joined: Mon Jan 06, 2014 9:40 pm

Re: 11991 - Easy Problem from Rujia Liu?

Post by bitaron » Mon Oct 05, 2015 5:33 pm

Run time error :( . please help

Code: Select all

#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
using namespace std;


int main(int argc, char **argv)
{
	std::ifstream infile;
	ofstream outfile;
	//outfile.open("12372Output.txt");
	//infile.open("11991.txt");
	//infile>>caseNumber;
	//cin>>caseNumber;
	while(1){
		int e,q,t;
		vector<long> db[100001] = {};
		
		//infile>>e;
		if(cin.eof()){
			break;
		}
		cin>>e;
	//	cout<<""<<e<<" ";
		
		//infile>>q;
		cin>>q;
		
		//cout<<q<<" ";
		for(int i=0;i<e;i++){
			//infile>>t;
			cin>>t;
			db[t].push_back(i);
		//	cout<<t;
		}
		int item,value;
		for(int i=0;i<q;i++){
			//infile>>value;
			//infile>>item;
			cin>>value;
			cin>>item;
		if((value)>db[item].size()){
				cout<<0<<"\n";
			}else{
				cout<<db[item].at(value-1)+1<<"\n";
			}
		}
		
		
	}

	return 0;
}



Post Reply

Return to “Volume 119 (11900-11999)”