Submission #285466

#TimeUsernameProblemLanguageResultExecution timeMemory
285466arnold518Discharging (NOI20_discharging)C++14
47 / 100
1056 ms17856 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e6; const ll INF = 1e15; int N; ll dp[MAXN+10], A[MAXN+10]; int main() { scanf("%d", &N); for(int i=1; i<=N; i++) scanf("%lld", &A[i]); reverse(A+1, A+N+1); A[0]=INF; vector<int> S; S.push_back(0); for(int i=1; i<=N; i++) { while(!S.empty() && A[S.back()]<=A[i]) S.pop_back(); S.push_back(i); } for(int i=1; i<S.size(); i++) { dp[i]=INF; for(int j=0; j<i; j++) { dp[i]=min(dp[i], dp[j]+A[S[j+1]]*S[i]); } } printf("%lld\n", dp[S.size()-1]); }

Compilation message (stderr)

Discharging.cpp: In function 'int main()':
Discharging.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i=1; i<S.size(); i++)
      |               ~^~~~~~~~~
Discharging.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
Discharging.cpp:17:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  for(int i=1; i<=N; i++) scanf("%lld", &A[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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...