이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "teams.h"
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using pii = pair<int, int>;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)
#define dforn(i, n) for(int i=n-1; i>=0; --i)
#define PB push_back
#define F first
#define S second
const int MAXN=500010, SQ=1010;
int n, aa[MAXN], bb[MAXN], uniq[SQ], req[SQ], arr[SQ][SQ];
void init(int N, int A[], int B[]) {
n=N;
forn(i, n) aa[i]=A[i], bb[i]=B[i];
}
int can(int m, int K[]) {
int suu=0, sz=0;
forn(i, m){
suu+=K[i];
if(suu>n) return 0;
}
sort(K, K+m);
forn(i, m){
if(i==0 || K[i]!=K[i-1]) uniq[sz]=K[i], req[sz]=1, ++sz;
else req[sz-1]++;
}
forn(i, sz) req[i]*=uniq[i];
forn(i, sz) forsn(j, i, sz) arr[i][j]=0;
forn(i, n){
int l = lower_bound(uniq, uniq+sz, aa[i]) - uniq;
int r = (upper_bound(uniq, uniq+sz, bb[i]) - uniq) - 1;
if(l<=r) arr[l][r]++;
}
forn(i, sz){
forsn(j, i, sz){
if(req[i]>arr[i][j]) req[i]-=arr[i][j], arr[i][j]=0;
else{
arr[i][j]-=req[i];
req[i]=0;
break;
}
}
if(req[i]>0) return 0;
forsn(j, i+1, sz) arr[i+1][j]+=arr[i][j];
}
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In function 'int can(int, int*)':
teams.cpp:37:45: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
37 | int l = lower_bound(uniq, uniq+sz, aa[i]) - uniq;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
teams.cpp:38:54: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
38 | int r = (upper_bound(uniq, uniq+sz, bb[i]) - uniq) - 1;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
# | 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... |