Submission #781751

#TimeUsernameProblemLanguageResultExecution timeMemory
781751RecursiveCoSemiexpress (JOI17_semiexpress)C++14
100 / 100
33 ms16976 KiB
// CF template, version 3.0 #include <bits/stdc++.h> using namespace std; #define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0) #define getTest int t; cin >> t #define eachTest for (int _var=0;_var<t;_var++) #define get(name) int (name); cin >> (name) #define out(o) cout << (o) #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); } #define sortl(name) sort((name).begin(), (name).end()) #define rev(name) reverse((name).begin(), (name).end()) #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++) #define decision(b) if (b){out("YES");}else{out("NO");} #define int long long signed main() { improvePerformance; //getTest; //eachTest { get(n); get(m); get(k); get(a); get(b); get(c); get(t); getList(m, stops); for (int& el: stops) el--; vector<int> els; int init = 0; forto(m - 1, i) { vector<int> cur(k - m + 1, -1); int s = stops[i]; int initial = b * s; int rightmost = (t - initial) / a + s; int loops = min(k - m, stops[i + 1] - stops[i] - 1); if (initial > t) { forto(loops, j) els.push_back(0); } else { if (rightmost >= stops[i + 1] - 1) { init += stops[i + 1] - stops[i]; forto(loops, j) els.push_back(0); } else { init += rightmost - s + 1; int initsum = rightmost - s + 1; int prev = initsum; forto(loops, _j) { int j = _j + 1; // put j extra stations in the i-th subsegment (bounded by express stations) int pos = rightmost + 1; initial = b * s + c * (pos - s); if (initial > t) { for (int l = j; l < loops; l++) els.push_back(0); break; } rightmost = (t - initial) / a + pos; if (rightmost >= stops[i + 1] - 1) { els.push_back(stops[i + 1] - stops[i] - prev); for (int l = j + 1; l < loops; l++) els.push_back(0); break; } els.push_back(rightmost - s + 1 - prev); prev = rightmost - s + 1; } } } } if (stops.back() * b <= t) init++; init--; sortl(els); rev(els); forto(k - m, i) init += els[i]; out(init); //} }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
semiexpress.cpp:25:9: note: in expansion of macro 'get'
   25 |         get(n);
      |         ^~~
semiexpress.cpp:10:23: warning: unnecessary parentheses in declaration of 'm' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
semiexpress.cpp:26:9: note: in expansion of macro 'get'
   26 |         get(m);
      |         ^~~
semiexpress.cpp:10:23: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
semiexpress.cpp:27:9: note: in expansion of macro 'get'
   27 |         get(k);
      |         ^~~
semiexpress.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
semiexpress.cpp:28:9: note: in expansion of macro 'get'
   28 |         get(a);
      |         ^~~
semiexpress.cpp:10:23: warning: unnecessary parentheses in declaration of 'b' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
semiexpress.cpp:29:9: note: in expansion of macro 'get'
   29 |         get(b);
      |         ^~~
semiexpress.cpp:10:23: warning: unnecessary parentheses in declaration of 'c' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
semiexpress.cpp:30:9: note: in expansion of macro 'get'
   30 |         get(c);
      |         ^~~
semiexpress.cpp:10:23: warning: unnecessary parentheses in declaration of 't' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
semiexpress.cpp:31:9: note: in expansion of macro 'get'
   31 |         get(t);
      |         ^~~
semiexpress.cpp:12:40: warning: unnecessary parentheses in declaration of 'stops' [-Wparentheses]
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                        ^
semiexpress.cpp:32:9: note: in expansion of macro 'getList'
   32 |         getList(m, stops);
      |         ^~~~~~~
semiexpress.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
semiexpress.cpp:12:76: note: in expansion of macro 'get'
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                                                            ^~~
semiexpress.cpp:32:9: note: in expansion of macro 'getList'
   32 |         getList(m, stops);
      |         ^~~~~~~
semiexpress.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
semiexpress.cpp:36:9: note: in expansion of macro 'forto'
   36 |         forto(m - 1, i) {
      |         ^~~~~
semiexpress.cpp:15:35: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
semiexpress.cpp:43:17: note: in expansion of macro 'forto'
   43 |                 forto(loops, j) els.push_back(0);
      |                 ^~~~~
semiexpress.cpp:15:35: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
semiexpress.cpp:47:21: note: in expansion of macro 'forto'
   47 |                     forto(loops, j) els.push_back(0);
      |                     ^~~~~
semiexpress.cpp:15:35: warning: unnecessary parentheses in declaration of '_j' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
semiexpress.cpp:52:21: note: in expansion of macro 'forto'
   52 |                     forto(loops, _j) {
      |                     ^~~~~
semiexpress.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
semiexpress.cpp:77:9: note: in expansion of macro 'forto'
   77 |         forto(k - m, i) init += els[i];
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...