#include <bits/stdc++.h>
using namespace std;
#define int long long
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int inf=1e18;
const int N=2e5+100;
const int mod=1e9+7;
struct edge{
int a,b;
};
vector<edge>r;
vector<edge>c;
int a[20005][20005];
int r1[20005];
int c1[20005];
signed main(){
boost;
int n,m;
cin>>n;
int cnt=0;
int l=1;
for(int i=1;i<=n;i++){
int a,b;
cin>>a>>b;
r.push_back({a,b});
for(int j=l;j<=l+b-1;j++){
r1[j]=a;
}
l+=b;
cnt+=b;
}
cin>>m;
int cnt1=0;
l=1;
priority_queue<pair<int,int> >q;
for(int i=1;i<=m;i++){
int a,b;
cin>>a>>b;
c.push_back({a,b});
cnt1+=b;
for(int j=l;j<=l+b-1;j++){
c1[j]=a;
q.push({a,j});
}
l+=b;
}
vector<pair<int,int> >v;
int ok=1;
for(int i=1;i<=cnt;i++){
while(r1[i]>0){
r1[i]--;
pair<int,int>p=q.top();
a[i][p.second]=1;
p.first--;
if(p.first<0){
ok=0;
break;
}
q.pop();
v.push_back(p);
}
if(ok==0){
break;
}
for(int j=0;j<v.size();j++){
q.push(v[j]);
}
v.clear();
}
cout<<ok;
}
Compilation message (stderr)
/tmp/cc5t0XP5.o: in function `main':
bodyguards.cpp:(.text.startup+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
bodyguards.cpp:(.text.startup+0x3e): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
bodyguards.cpp:(.text.startup+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
bodyguards.cpp:(.text.startup+0x84): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/cc5t0XP5.o
bodyguards.cpp:(.text.startup+0x98): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(globals_io.o)
bodyguards.cpp:(.text.startup+0xbd): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/cc5t0XP5.o
bodyguards.cpp:(.text.startup+0xc4): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/cc5t0XP5.o
bodyguards.cpp:(.text.startup+0xdd): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/cc5t0XP5.o
bodyguards.cpp:(.text.startup+0x182): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/cc5t0XP5.o
bodyguards.cpp:(.text.startup+0x1b7): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/cc5t0XP5.o
bodyguards.cpp:(.text.startup+0x1be): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/13/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1f): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1ed): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x252): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2bc): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x316): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x50f): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x57d): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5f0): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x654): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status