이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ii,ll>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "teams.h"
const ll siz = 500005;
ll a[siz],b[siz];
ll n;
void init(int N, int A[], int B[]){
n = N;
f(i,0,n){
a[i] = A[i];
b[i] = B[i];
}
}
int can(int M, int K[]) {
vector<ii>arr;
set<iii>ex;
ll pos = 0;
f(i,0,n){
arr.pb(ii(a[i],b[i]));
}
sort(K,K+M);
sort(all(arr));
bool ok = true;
f(i,0,M){
while(pos < n && arr[pos].F <= K[i]){
ex.insert(iii(ii(arr[pos].S,arr[pos].F),pos));
pos++;
}
while(!ex.empty()){
auto it = ex.begin();
if((*it).F.F < K[i]){
ex.erase((*it));
}
else{
break;
}
}
if(ex.size() < K[i]){
ok = false;
break;
}
else{
f(j,0,K[i]){
auto it = ex.begin();
ex.erase((*it));
}
}
}
return ok;
}
/*
int main() {
int N;
cin>>N;
int *A = (int*)malloc(sizeof(int)*(unsigned int)N);
int *B = (int*)malloc(sizeof(int)*(unsigned int)N);
for (int i = 0; i < N; ++i) {
cin>>A[i]>>B[i];
}
init(N, A, B);
int Q;
cin>>Q;
for (int i = 0; i < Q; ++i) {
int M;
cin>>M;
int *K = (int*)malloc(sizeof(int)*(unsigned int)M);
for (int j = 0; j < M; ++j) {
cin>>K[j];
}
printf("%d\n", can(M, K));
}
return 0;
}
*/
/*
4
2 4
1 2
2 3
2 3
2
2 1 3
2 1 1
*/
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In function 'int can(int, int*)':
teams.cpp:60:22: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
60 | if(ex.size() < K[i]){
| ~~~~~~~~~~^~~~~~
# | 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... |