이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "robots.h"
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> ti;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ld,ld> pld;
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front
#define ff first
#define ss second
#define MOD (ll)(1000000007)
#define INF (ll) (1e18)
#define all(v) (v).begin(),(v).end()
const int nx[8] = {0, 0, 1, -1,1,1,-1,-1}, ny[8] = {1, -1, 0, 0,1,-1,1,-1}; //East, West, South, North+
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;}
ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
////////////******SOLUTION******\\\\\\\\\\\
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
int wmax = 0;
int smax = 0;
for(int i = 0; i < A; i ++)
wmax = max(wmax,X[i]);
for(int i = 0; i < B; i ++)
smax = max(smax,Y[i]);
for(int i = 0; i < T; i ++)
if(W[i] >= wmax && S[i] >= smax)
return -1;
// subtask 1
if(T == 2 && A+B == 2)
{
if(A == 2)
{
if(min(X[0],X[1]) > min(W[0],W[1]) && max(X[0],X[1]) > max(W[0],W[1]))
return 1;
}
else if(B == 2)
{
if(min(Y[0],Y[1]) > min(S[0],S[1]) && max(Y[0],Y[1]) > max(S[0],S[1]))
return 1;
}
else
{
if((X[0] > W[0] && Y[0] > S[1]) || (X[0] > W[1] && Y[0] > S[0]))
return 1;
}
return 2;
}
if(B == 0) // subtask 2
{
sort(W,W+T);
sort(X,X+A);
int j = 0;
int ans = 1;
for(int i= 0; i<T; i ++)
{
if(j >= A)
{
ans ++;
j = 0;
}
int debut = j;
int fin = A -1;
j = A;
while(debut <= fin)
{
int mid = (debut+fin)/2;
if(X[mid] > W[i])
{
j = mid;
fin = mid - 1;
}
else
debut = mid + 1;
}
j ++;
}
return ans;
}
return 1;
}
/*
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int A, B, T;
cin >> A >> B >> T;
int X[A], Y[B], W[T], S[T];
for(int i = 0; i < A; i ++)
{
int x; cin >> x;
X[i]=x;
}
for(int i = 0; i< B; i ++)
{
int y; cin >> y;
Y[i]=y;
}
for(int i = 0; i < T; i ++)
{
int w, s;
cin >> w >> s;
W[i] = w;
S[i] = s;
}
cout << putaway(A,B,T,X,Y,W,S) << '\n';
}
/*
5 0 6
2 3 4 5 6
1 80
2 80
3 80
4 80
1 80
5 80
*/
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp:25:1: warning: multi-line comment [-Wcomment]
25 | ////////////******SOLUTION******\\\\\\\\\\\
| ^
robots.cpp:119:1: warning: "/*" within comment [-Wcomment]
119 | /*
|
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |