답안 #1084903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1084903 2024-09-07T08:04:55 Z PakinDioxide 쌀 창고 (IOI11_ricehub) C++17
17 / 100
1000 ms 2956 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

int l = 1, r = 0;
vector <pair <int, int>> p;

long long recal() {
    long long sum = 0;
    int ll = l, rr = r;
    while (ll < rr) sum += p[rr--].first - p[ll++].first;
    return sum;
}

int besthub(int n, int m, int a[], long long x) {
    p.emplace_back(0, 0);
    for (int j = 0; j < n; j++) {
        int i = a[j];
        if (p[p.size()-1].first != i) p.emplace_back(i, p[p.size()-1].second + 1);
        else p[p.size()-1].second++;
    }
    // for (auto [x, y] : p) printf("%d %d\n", x, y);
    // printf("S %d\n", p.size());
    int mx = 0;
    while (r < p.size() - 1) {
        r++;
        while (recal() > x) l++;
        mx = max(mx, p[r].second - p[l-1].second);
        // printf("MX %d\n", mx);
    }
    return mx;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:26:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     while (r < p.size() - 1) {
      |            ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 3 ms 860 KB Output is correct
3 Execution timed out 1094 ms 2956 KB Time limit exceeded
4 Halted 0 ms 0 KB -