제출 #123666

#제출 시각아이디문제언어결과실행 시간메모리
123666wilwxkSemiexpress (JOI17_semiexpress)C++14
100 / 100
2 ms504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN=3e4+5; priority_queue<tuple<ll, ll, ll> > pq; int n, m, k; ll x, y, z, q; ll v[MAXN], custo[MAXN]; int respf; int main() { scanf("%d %d %d", &n, &m, &k); scanf("%lld %lld %lld", &x, &y, &z); scanf("%lld", &q); for(int i=1; i<=m; i++) { scanf("%lld", &v[i]); custo[i]=(v[i]-1)*y; if(custo[i]<=q) respf++; if(i!=1) { if(custo[i-1]>=q) continue; ll posso=(q-custo[i-1])/x; ll sobrou=v[i]-v[i-1]-1; posso=min(posso, sobrou); respf+=posso; ll fcusto=custo[i-1]+z*(posso+1); ll fposso=(q-fcusto)/x+1; fposso=min(fposso, sobrou-posso); // printf("%d:: %lld %lld // (%lld %lld %lld) -- respf %d\n", i, posso, sobrou, fposso, fcusto, sobrou-posso, respf); if(fposso>0&&fcusto<=q) pq.push({fposso, fcusto, sobrou-posso}); } } // printf("tenho %d\n", respf); // while(pq.size()) printf("(%lld %lld %lld)\n", get<0>(pq.top()), get<1>(pq.top()), get<2>(pq.top())), pq.pop(); k-=m; while(k--) { if(pq.empty()) break; ll fposso, fcusto, fsobrou; tie(fposso, fcusto, fsobrou)=pq.top(); pq.pop(); respf+=fposso; fsobrou-=fposso; fcusto+=fposso*z; fposso=(q-fcusto)/x+1; fposso=min(fposso, fsobrou); // printf("add %lld %lld %lld\n", fposso, fcusto, fsobrou); if(fposso>0&&fcusto<=q) pq.push({fposso, fcusto, fsobrou}); } printf("%d\n", respf-1); }

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

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld", &x, &y, &z);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &q);
  ~~~~~^~~~~~~~~~~~
semiexpress.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &v[i]);
   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...