답안 #1036287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036287 2024-07-27T08:13:27 Z abyyskit 로봇 (IOI13_robots) C++14
76 / 100
3000 ms 19536 KB
#include "robots.h"
#include <bits/stdc++.h>
 
typedef int ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
 
using namespace std;
 
 
bool lmao(vector<ll> stuff, vector<ll> robot, ll k){
    sort(stuff.begin(), stuff.end());
    sort(robot.begin(), robot.end());
    ll cur = 0;
    for (auto&i : robot){
        ll cnt = 0;
        while (cur < stuff.size() && cnt < k){
            if (stuff[cur] < i) cur++, cnt++;
            else break;
        }
    }
    if (cur == stuff.size()) return true;
    else return false;
}
 
 
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
    vector<ll> x (X, X + A);
    vector<ll> y (Y, Y + B);
    vector<pair<ll, ll>> lol(T);

    FOR(i,0,T) lol[i] = {W[i], S[i]};
 
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    sort(lol.begin(), lol.end());
 
 
    ll l = 0;
    ll r = T+1;
    while (l<r){
        ll mid = (l+r)/2;
        priority_queue<ll> sus;
        ll cur = 0;
 
        for (auto&i : x){
            while (cur < lol.size()){
                if (lol[cur].first < i) sus.push(lol[cur].second), cur++;
                else break;
            }
            FOR(k,0,mid){
                if (sus.size()) sus.pop();
            }
        }
        while (cur < lol.size()) sus.push(lol[cur].second), cur++;
        vector<ll> idk;
        while (sus.size()){
            idk.push_back(sus.top());
            sus.pop();
        }
 
        if (lmao(idk,y,mid)) r = mid;
        else l = mid+1;
    }
    if (l==T+1) return -1;
    else return l;
 
}

Compilation message

robots.cpp: In function 'bool lmao(std::vector<int>, std::vector<int>, ll)':
robots.cpp:17:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         while (cur < stuff.size() && cnt < k){
      |                ~~~~^~~~~~~~~~~~~~
robots.cpp:22:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     if (cur == stuff.size()) return true;
      |         ~~~~^~~~~~~~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:47:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             while (cur < lol.size()){
      |                    ~~~~^~~~~~~~~~~~
robots.cpp:55:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         while (cur < lol.size()) sus.push(lol[cur].second), cur++;
      |                ~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 440 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Execution timed out 3099 ms 14312 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 440 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 12 ms 860 KB Output is correct
17 Correct 13 ms 860 KB Output is correct
18 Correct 17 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Execution timed out 3047 ms 19536 KB Time limit exceeded
11 Halted 0 ms 0 KB -