이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#include "teams.h"
vector<pair<int, int> > st;
bool comp(pair<int, int> p1, pair<int, int> p2){
if(p1.second == p2.second) return (p1.first < p2.first);
else return (p1.second < p2.second);
}
void init(int N, int A[], int B[]){
for(int i = 0; i < N; i++){
st.pb({A[i], B[i]});
}
sort(st.begin(), st.end(), comp);
}
int can(int M, int K[]) {
sort(K, K + M);
vector<int> cnt(M);
for(int i = 0; i < st.size(); i++){
auto starti = lower_bound(K, K + M, st[i].first) - K;
if(starti >= M) continue;
auto endi = upper_bound(K, K + M, st[i].second) - K;
for(int j = starti; j < endi; j++){
if(cnt[j] < K[j]){
cnt[j]++;
break;
}
}
}
bool ok = 1;
for(int i = 0; i < M; i++){
if(cnt[i] != K[i]) ok = 0;
}
return ok;
}
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In function 'int can(int, int*)':
teams.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 0; i < st.size(); i++){
| ~~^~~~~~~~~~~
teams.cpp:28:21: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
28 | for(int j = starti; j < endi; j++){
| ^~~~~~
# | 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... |