Submission #46320

#TimeUsernameProblemLanguageResultExecution timeMemory
46320rajarshi_basuTeams (IOI15_teams)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define pb(a) push_back(a)
#define vi vector<int>
#define ii pair<int,int>
#define iii pair<pair<int,int>, int>
#define mp(a,b) make_pair(a,b)

using namespace std;

#define ff first
#define ss second

int n;
int* a;
int* b;

ii* arr;
bool comp(ii a,ii b){
  return a.ss > b.ss;
}
class Compare
{
public:
    bool comp(ii a,ii b){
  return a.ss > b.ss;
} 

    bool operator() (ii a, ii b)
    {
        return comp(a,b);
    }
};


void init(int N,int* A,int* B){
  n=N;
  a = A;
  b = B;
  arr = new ii[n];
  FOR(i,n)arr[i].ff = a[i];
  FOR(i,n)arr[i].ss = b[i];
  sort(arr,arr+n);
}

bool call(int m,int* k){
  priority_queue<ii, vector<ii> , Compare > pq;
  int PTR = 0;
  FOR(i,m){
    while(arr[PTR].ff<=k[i])pq.push(arr[PTR++]);
    int ctr = k[i];
    while(!pq.empty() && pq.top().ss < ctr)pq.pop();
    while(!pq.empty() && pq.top().ss < k[i] && ctr > 0){
      pq.pop();
      ctr--;
    }
    if(ctr > 0)return 0;
  }
  return 1;

}

Compilation message (stderr)

teams.cpp: In function 'bool comp(std::pair<int, int>, std::pair<int, int>)':
teams.cpp:28:20: warning: declaration of 'b' shadows a global declaration [-Wshadow]
 bool comp(ii a,ii b){
                    ^
teams.cpp:25:6: note: shadowed declaration is here
 int* b;
      ^
teams.cpp:28:20: warning: declaration of 'a' shadows a global declaration [-Wshadow]
 bool comp(ii a,ii b){
                    ^
teams.cpp:24:6: note: shadowed declaration is here
 int* a;
      ^
teams.cpp: In member function 'bool Compare::comp(std::pair<int, int>, std::pair<int, int>)':
teams.cpp:34:25: warning: declaration of 'b' shadows a global declaration [-Wshadow]
     bool comp(ii a,ii b){
                         ^
teams.cpp:25:6: note: shadowed declaration is here
 int* b;
      ^
teams.cpp:34:25: warning: declaration of 'a' shadows a global declaration [-Wshadow]
     bool comp(ii a,ii b){
                         ^
teams.cpp:24:6: note: shadowed declaration is here
 int* a;
      ^
teams.cpp: In member function 'bool Compare::operator()(std::pair<int, int>, std::pair<int, int>)':
teams.cpp:39:5: warning: declaration of 'b' shadows a global declaration [-Wshadow]
     {
     ^
teams.cpp:25:6: note: shadowed declaration is here
 int* b;
      ^
teams.cpp:39:5: warning: declaration of 'a' shadows a global declaration [-Wshadow]
     {
     ^
teams.cpp:24:6: note: shadowed declaration is here
 int* a;
      ^
/tmp/ccPISb8P.o: In function `main':
grader.c:(.text.startup+0x5f6): undefined reference to `can(int, int*)'
collect2: error: ld returned 1 exit status