Submission #138964

#TimeUsernameProblemLanguageResultExecution timeMemory
138964SirCenessRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
2061 ms10968 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; } }; ll getans(int smin, int tmax, vector<int>& s, vector<int>& t){ int n = (int)s.size(); 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; } long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int) s.size(); ll ans = 1000000000000000000; for (int i = 0; i < n; i++){ for (int j = i+1; j < n; j++){ ans = min(ans, getans(i, j, s, t)); ans = min(ans, getans(j, i, s, t)); } } return ans; }

Compilation message (stderr)

railroad.cpp: In function 'll getans(int, int, std::vector<int>&, std::vector<int>&)':
railroad.cpp:35: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...