QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#872388#8588. Amusement ParkZiqt7PhR0 13ms6508kbC++20930b2025-01-26 01:12:082025-01-26 01:12:08

Judging History

你现在查看的是最新测评结果

  • [2025-01-26 01:12:08]
  • 评测
  • 测评结果:0
  • 用时:13ms
  • 内存:6508kb
  • [2025-01-26 01:12:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, s;
    cin >> n >> s;
    vector<pair<int, int>> students;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < s; ++j) {
            int h;
            cin >> h;
            students.emplace_back(h, i);
        }
    }
    ranges::sort(students);
    
    vector<int> cnt(n);
    int r = 0, zero_cnt = n, ans = 1e9;
    for (int l = 0; l < n * s; ++l) {
        while (r < n * s && zero_cnt) {
            if (cnt[students[r].second]++ == 0) {
                --zero_cnt;
            }
            ++r;
        }
        if (zero_cnt == 0) {
            ans = min(ans, students[r - 1].first - students[l].first);
        }
        if (--cnt[students[l].second] == 0) {
            ++zero_cnt;
        }
    }
    cout << ans << '\n';
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3456kb

input:

7
1 2 0
1 6 0
1 6 1
3 5
2 2
1 3 0
3 123456789012

output:

6

result:

wrong answer 1st lines differ - expected: '2', found: '6'

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 13ms
memory: 6508kb

input:

200000
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0
1 1 0...

output:

1

result:

wrong answer 1st lines differ - expected: '199999', found: '1'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%