제출 #897862

#제출 시각아이디문제언어결과실행 시간메모리
897862batmendbar추월 (IOI23_overtaking)C++17
39 / 100
3542 ms696 KiB
#include "overtaking.h" #include<bits/stdc++.h> using namespace std; struct Car { Car(int speed, long long cur_time, int number) : speed{speed}, cur_time{cur_time}, number{number} {} int number; int speed; long long cur_time; bool operator<(const Car &other) const{ if (cur_time != other.cur_time) { return cur_time > other.cur_time; } else { return speed > other.speed; } } }; vector<Car> cars; vector<int> stations; void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S) { for (int i = 0; i < N; i++) { cars.push_back(Car(W[i], T[i], i)); } cars.push_back(Car(X, 0, N)); stations = S; stations.push_back(L); return; } long long arrival_time(long long Y) { cars.back().cur_time = Y; auto cars1 = cars; // for (Car c : cars1) { // cout << c.cur_time << ' ' << c.speed << '\n'; // } for (int i = 0; i < stations.size(); i++) { long long dist; if (i == 0) { continue; } else { dist = stations[i] - stations[i-1]; } sort(cars1.begin(), cars1.end()); vector<Car> temp; long long slowest_time = -1; while(!cars1.empty()) { slowest_time = max(slowest_time, cars1.back().cur_time + dist * cars1.back().speed); cars1.back().cur_time = slowest_time; temp.push_back(cars1.back()); cars1.pop_back(); } cars1 = temp; } for (auto car : cars1) { if (car.number == cars1.size() - 1) { return car.cur_time; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

overtaking.cpp: In constructor 'Car::Car(int, long long int, int)':
overtaking.cpp:9:15: warning: 'Car::cur_time' will be initialized after [-Wreorder]
    9 |     long long cur_time;
      |               ^~~~~~~~
overtaking.cpp:7:9: warning:   'int Car::number' [-Wreorder]
    7 |     int number;
      |         ^~~~~~
overtaking.cpp:6:5: warning:   when initialized here [-Wreorder]
    6 |     Car(int speed, long long cur_time, int number) : speed{speed}, cur_time{cur_time}, number{number} {}
      |     ^~~
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i = 0; i < stations.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~
overtaking.cpp:64:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Car>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         if (car.number == cars1.size() - 1) {
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...