답안 #1083334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083334 2024-09-03T02:09:27 Z sonamoo Gap (APIO16_gap) C++14
100 / 100
49 ms 3316 KB
#include "gap.h"
#include <bits/stdc++.h>
#define pii pair<ll,ll>
#define ll long long

using namespace std;

pii query(ll s , ll e) {
    pii ret;
    MinMax(s , e , &ret.first , &ret.second);
    return ret;
}

vector<ll> v;

long long findGap(int T, int N)
{

    if (T==1) {
        ll s = 0 , e = 2e18;
        while(N > 0) {
            pii ret = query(s , e);
            if (ret.first!=-1) v.push_back(ret.first);
            if (ret.second!=-1) v.push_back(ret.second);
            s = ret.first+1 , e = ret.second-1; N -= 2;
        }
        sort(v.begin() , v.end());
        ll ans=0;
        for (int i = 0; i < v.size()-1; i++) ans = max(ans , v[i+1]-v[i]);
        return ans;
    }

    pii ret = query(0 , 2e18);
    ll mi = ret.first, ma = ret.second;
    ll gap = (ma-mi+N-2)/(N-1);
    for (ll i = mi; i <= ma; i += gap+1) {
        pii ret=query(i , i+gap);
        if (ret.first!=-1) v.push_back(ret.first);
        if (ret.second!=-1) v.push_back(ret.second);
    }
    ll ans=0;
    for (int i = 0; i < v.size()-1; i++) ans = max(ans , v[i+1]-v[i]);

	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int i = 0; i < v.size()-1; i++) ans = max(ans , v[i+1]-v[i]);
      |                         ~~^~~~~~~~~~~~
gap.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i = 0; i < v.size()-1; i++) ans = max(ans , v[i+1]-v[i]);
      |                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 8 ms 876 KB Output is correct
17 Correct 8 ms 892 KB Output is correct
18 Correct 8 ms 980 KB Output is correct
19 Correct 10 ms 980 KB Output is correct
20 Correct 6 ms 980 KB Output is correct
21 Correct 30 ms 2328 KB Output is correct
22 Correct 33 ms 2256 KB Output is correct
23 Correct 30 ms 2256 KB Output is correct
24 Correct 35 ms 2256 KB Output is correct
25 Correct 26 ms 2256 KB Output is correct
26 Correct 29 ms 2256 KB Output is correct
27 Correct 30 ms 2256 KB Output is correct
28 Correct 30 ms 2256 KB Output is correct
29 Correct 30 ms 2256 KB Output is correct
30 Correct 25 ms 2256 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 10 ms 980 KB Output is correct
17 Correct 9 ms 980 KB Output is correct
18 Correct 10 ms 1004 KB Output is correct
19 Correct 10 ms 980 KB Output is correct
20 Correct 4 ms 600 KB Output is correct
21 Correct 36 ms 2256 KB Output is correct
22 Correct 36 ms 2256 KB Output is correct
23 Correct 38 ms 2364 KB Output is correct
24 Correct 37 ms 2256 KB Output is correct
25 Correct 36 ms 3316 KB Output is correct
26 Correct 39 ms 2320 KB Output is correct
27 Correct 49 ms 2248 KB Output is correct
28 Correct 36 ms 2248 KB Output is correct
29 Correct 36 ms 2252 KB Output is correct
30 Correct 27 ms 1588 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct