제출 #138963

#제출 시각아이디문제언어결과실행 시간메모리
138963SirCenessRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
101 ms11112 KiB
#include "railroad.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define inside sl<=l&&r<=sr #define outside r<sl||sr<l #define orta ((l+r)>>1) #define INF 1000000009 #define mod 1000000007 #define ppair(x); cerr << "(" << x.first << ", " << x.second << ")\n"; #define bas(x) #x << ": " << x << " " #define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n"; #define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n"; using namespace std; typedef long long ll; struct node { ll s, t; bool operator<(const node& a){ return s+t > a.s + a.t; } }; long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int) s.size(); int smin = 0; int minn = s[0]; for (int i = 0; i < s.size(); i++) if (s[i] < minn){ minn = s[i]; smin = i; } int tmax = 0; int maxx = t[0]; for (int i = 0; i < t.size(); i++) if (t[i] > maxx){ maxx = t[i]; tmax = i; } vector<node> arr; for (int i = 0; i < n; i++){ if (i != smin && i != tmax) arr.pb({s[i], t[i]}); } sort(arr.begin(), arr.end()); arr.pb({s[tmax], t[tmax]}); ll ans = 0; ll last = t[smin]; for (int i = 0; i < arr.size(); i++){ ans += max((ll)0, last - arr[i].s); last = arr[i].t; } return ans; }

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

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < s.size(); i++) if (s[i] < minn){
                  ~~^~~~~~~~~~
railroad.cpp:36:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < t.size(); i++) if (t[i] > maxx){
                  ~~^~~~~~~~~~
railroad.cpp:49:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < arr.size(); i++){
                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...