QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#73679 | #2616. Attack Order | xlwang# | WA | 2ms | 3468kb | C++14 | 2.3kb | 2023-01-27 15:59:05 | 2023-01-27 15:59:08 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define randfind(l,r) (rand()%((r)-(l)+1)+(l))
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
using namespace std;
inline int read(){
int x=0;
bool f=0;
char c=getchar();
while(!isdigit(c)) f|=(c=='-'),c=getchar();
while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
//inline void init(){
// int t=read();
// while(t--) work();
//}
const int Maxn=1e2+10;
int a[Maxn],b[Maxn];
int n;
struct node{
int val;
int sum;
bool operator < (const node &x) const {
return val<x.val;
}
}e[Maxn];
priority_queue<node> q;
struct node1{
int val,sum;
bool operator < (const node1 &x) const {
return sum>x.sum;
}
};
priority_queue<node1> q1;
inline bool check(int x){
while(!q1.empty()) q1.pop();while(!q.empty()) q.pop();
fr(i,1,n){
if(i==x) continue;
node1 tmp;
tmp.sum=e[i].sum,tmp.val=e[i].val;
q1.push(tmp);
}
int lst=a[x];
fr(i,1,n-1){
while(!q1.empty() && q1.top().sum<=lst) {
node1 tmp;
tmp=q1.top();q1.pop();
node ttmp;
ttmp.sum=tmp.sum,ttmp.val=tmp.val;
q.push(ttmp);
}
if(q.empty() || q.top().sum>lst){
return false;
}
lst=q.top().val;
q.pop();
}
return true;
}
inline void work(){
n=read();
fr(i,1,n) a[i]=read(),b[i]=read();
if(n==2){puts("Yes");return;}
fr(i,1,n) e[i].val=a[i];
int sum=0;
fr(i,1,n) sum+=b[i];
fr(i,1,n) e[i].sum=sum-b[i];
fr(i,1,n) if(check(i)){
puts("Yes");
return;
}
puts("No");
return;
}
inline void init(){
int t=read();
while(t--) work();
}
signed main(){
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
init();
// printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3468kb
input:
3 2 15 25 10 5 3 7 0 7 3 10 0 3 10 10 20 20 30 30
output:
Yes Yes No
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3312kb
input:
1000 4 0 1 0 2 2 2 0 0 4 2 2 1 1 1 1 0 0 4 2 1 1 2 1 0 2 1 3 2 1 1 0 1 1 4 2 0 2 2 1 2 1 2 3 1 0 3 0 0 3 4 1 1 1 0 1 2 1 2 2 1 2 3 1 4 1 2 1 0 2 0 0 2 2 3 3 0 2 4 2 0 1 0 2 1 0 1 3 1 1 1 0 0 3 4 1 1 2 1 0 2 1 1 4 1 2 2 2 1 0 2 1 4 0 0 1 0 0 1 0 1 3 0 1 2 3 0 0 3 3 1 3 2 1 1 4 1 0 0 0 1 1 2 1 4 2 1 1...
output:
No No No Yes No Yes No Yes No Yes Yes No No No No No Yes No No No No No No Yes No No No Yes Yes No Yes No No Yes No No No No No No No No No No No No No No No Yes No No No No Yes No No Yes No Yes No No Yes No No No No No No No No Yes Yes No No No No No No No No No No No No No No No No Yes Yes No Yes ...
result:
wrong answer expected NO, found YES [4th token]