이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "teams.h"
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab (int x ) { return (x>0?x:-x); }
const int MaxN = 5e5+5;
pi st[MaxN];
int n ,out[MaxN],pr[MaxN];
vector<int> in[MaxN];
void init(int N,int a[],int b[]){
n = N ;
for(int i = 0 ; i < n ;i++ ){
st[i]={a[i],b[i]};
in[a[i]].pb(b[i]);
out[b[i]]++;
}
sort(st,st+n);
}
int can(int M,int K[]){
sort(K,K+M);
for(int i = 0 ; i < M ; i++ )pr[K[i]]++;
priority_queue<int,vector<int>,greater<int> >q ;
int done = 0 , x= 0;
for(int i = 1 ; i <= n ; i++ ){
for(int j : in[i])
q.push(j);
if( pr[i] ){
if( q.size() >= pr[i] ){
done ++ ;
while( pr[i]-- ){
out[q.top()]--;
q.pop();
}
}else return 0;
}
while( !q.empty() && q.top() == i )q.pop();
}
return done == M ;
}
// int main(){
// int a[]={1,2,2,2},b[]={2,3,3,4};
// init(4,a,b);
// int K[]={1,3},KK[]={1,1};
// cout << can(2,K)<<" " << can(2,KK)<<endl;
// }
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In function 'int can(int, int*)':
teams.cpp:44:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if( q.size() >= pr[i] ){
~~~~~~~~~^~~~~~~~
teams.cpp:39:17: warning: unused variable 'x' [-Wunused-variable]
int done = 0 , x= 0;
^
# | 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... |