답안 #915051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915051 2024-01-23T08:57:09 Z vjudge1 Roller Coaster Railroad (IOI16_railroad) C++17
0 / 100
57 ms 8512 KB
#include "railroad.h"

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

long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
        int n = (int)s.size();

        vector<int> good, bad;
        for (int i = 0; i < n; i++) {
                if (s[i] >= t[i]) {
                        good.push_back(i);
                } else {
                        bad.push_back(i);
                }
        }
        sort(good.begin(), good.end(), [&](int i, int j) {
                return s[i] == s[j] ? t[i] < t[j] : s[i] < s[j];
        });
        sort(bad.begin(), bad.end(), [&](int i, int j) {
                return t[i] == t[j] ? s[i] < s[j] : t[i] < t[j];
        });
        int j = 0;
        int last_t = 1;
        for (int i = 0; i < good.size(); i++) {
                while (j < bad.size() && last_t <= s[bad[j]] && t[bad[j]] <= s[good[i]]) {
                        j++;
                }
        }
        while (j < bad.size() && last_t <= s[bad[j]]) {
                j++;
        }
        return j == bad.size() ? 0 : 1;
}

Compilation message

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:25:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int i = 0; i < good.size(); i++) {
      |                         ~~^~~~~~~~~~~~~
railroad.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                 while (j < bad.size() && last_t <= s[bad[j]] && t[bad[j]] <= s[good[i]]) {
      |                        ~~^~~~~~~~~~~~
railroad.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         while (j < bad.size() && last_t <= s[bad[j]]) {
      |                ~~^~~~~~~~~~~~
railroad.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         return j == bad.size() ? 0 : 1;
      |                ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB n = 2
2 Correct 0 ms 600 KB n = 2
3 Correct 1 ms 344 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 1 ms 348 KB n = 2
6 Incorrect 0 ms 348 KB answer is not correct: 0 instead of 523688153
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB n = 2
2 Correct 0 ms 600 KB n = 2
3 Correct 1 ms 344 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 1 ms 348 KB n = 2
6 Incorrect 0 ms 348 KB answer is not correct: 0 instead of 523688153
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 8512 KB n = 199999
2 Incorrect 57 ms 8352 KB answer is not correct: 0 instead of 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB n = 2
2 Correct 0 ms 600 KB n = 2
3 Correct 1 ms 344 KB n = 2
4 Correct 0 ms 348 KB n = 2
5 Correct 1 ms 348 KB n = 2
6 Incorrect 0 ms 348 KB answer is not correct: 0 instead of 523688153
7 Halted 0 ms 0 KB -