이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"teams.h"
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define NS 110
vector<P> v;
int dat[NS];
void init(int N,int A[],int B[]){
rep(i,N)v.push_back(make_pair(B[i],A[i]));
sort(v.begin(),v.end());
rep(i,NS)dat[i]=0;
}
void add(int K){
rep(i,v.size()){
if(v[i].second<=K&&dat[i]==0)dat[i]=1;
}
}
void erase(int n){
for(int i=0;i<=n;i++){
if(dat[i]==1)dat[i]=2;
}
}
int sum(int n){
ll res=0;
for(int i=0;i<=n;i++){
res+=(dat[i]==1);
}
return res;
}
int can(int M,int K[]){
rep(i,NS)dat[i]=0;
sort(K,K+M);
rep(i,M){
add(K[i]);
ll l,r,mid;
l=-1,r=v.size();
while(l<r-1){
mid=(l+r)>>1;
(v[mid].first<K[i]?l:r)=mid;
}
erase(l);
l=-1,r=v.size();
while(l<r-1){
mid=(l+r)>>1;
(sum(mid)>=K[i]?r:l)=mid;
}
if(r==v.size())return 0;
erase(r);
}
return 1;
}
/*
int main(){
int n,a[110],b[110];
cin>>n;
rep(i,n)cin>>a[i]>>b[i];
init(n,a,b);
while(1){
int m,k[110];
cin>>m;
rep(i,m)cin>>k[i];
cout<<(can(m,k)?"YES":"NO")<<endl;
}
}*/
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In function 'void add(int)':
teams.cpp:11:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define rep(i,n) for(int i=0;i<n;i++)
teams.cpp:25:6:
rep(i,v.size()){
~~~~~~~~~~
teams.cpp:25:2: note: in expansion of macro 'rep'
rep(i,v.size()){
^~~
teams.cpp: In function 'int sum(int)':
teams.cpp:39:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
return res;
^~~
teams.cpp: In function 'int can(int, int*)':
teams.cpp:53:10: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
erase(l);
^
teams.cpp:57:12: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
(sum(mid)>=K[i]?r:l)=mid;
^
teams.cpp:59:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(r==v.size())return 0;
~^~~~~~~~~~
teams.cpp:60:10: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
erase(r);
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |