Submission #531733

#TimeUsernameProblemLanguageResultExecution timeMemory
531733cig32Semiexpress (JOI17_semiexpress)C++17
18 / 100
1 ms332 KiB
#include "bits/stdc++.h" using namespace std; const int MAXN = 1e5 + 10; const int MOD = 1e9 + 7; #define int long long mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x, int y) { int u = uniform_int_distribution<int>(x, y)(rng); return u; } void solve(int tc) { int N, M, K; cin >> N >> M >> K; int A, B, C; cin >> A >> B >> C; int T; cin >> T; int S[M+1]; for(int i=1; i<=M; i++)cin >> S[i]; int dist[N+1]; dist[1] = 0; int cur = 2; for(int i=2; i<=N; i++) { if(S[cur] == i) dist[i] = dist[S[cur - 1]] + (i - S[cur - 1]) * B, cur++; else dist[i] = dist[i-1] + A; } vector<queue<int> > v; int ans = 0; vector<int> st; for(int i=1; i<M; i++) { queue<int> r; for(int j=S[i]+1; j<S[i+1]; j++) { r.push(j); } while(r.size()) { if(dist[r.front()] <= T) { ans++; r.pop(); } else { break; } } v.push_back(r); st.push_back(S[i]); } vector<int> owo; owo.resize((int)v.size()); for(int i=1; i<=K-M; i++) { vector<pair<int, int> > w; for(int j=0; j<v.size(); j++) { if(v[j].empty()) continue; w.push_back({dist[v[j].front()] - owo[j], j}); } if(w.empty()) break; sort(w.begin(), w.end()); int idx = w[0].second; owo[idx] = (v[idx].front() - st[idx]) * (A - C); int net = 0; while(v[idx].size()) { if(dist[v[idx].front()] - owo[idx] <= T) { ans++; v[idx].pop(); net++; } else { break; } } if(!net) { while(v[idx].size()) v[idx].pop(); i--; continue; } } for(int i=2; i<=M; i++) { if(dist[S[i]] <= T) ans++; } cout << ans << "\n"; } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for(int i=1; i<=t; i++) solve(i); }

Compilation message (stderr)

semiexpress.cpp: In function 'void solve(long long int)':
semiexpress.cpp:49:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::queue<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int j=0; j<v.size(); j++) {
      |                  ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...