Submission #854402

#TimeUsernameProblemLanguageResultExecution timeMemory
854402pliamFancy Fence (CEOI20_fancyfence)C++17
12 / 100
122 ms262144 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 100005 typedef long long ll; #define MOD (ll)1e9+7 #define INF (ll)2e9 /* Brute force N^4 */ int N, L; ll h[MAXN], w[MAXN]; vector<ll> nh; int main(){ scanf("%d",&N); for(int i=0;i<N;i++){ scanf("%lld",&h[i]); } for(int i=0;i<N;i++){ scanf("%lld",&w[i]); for(int j=0;j<w[i];j++){ L++; nh.push_back(h[i]); } } ll ans=0; for(int i=0;i<L;i++){ // printf("%lld\n", nh[i]); for(int j=0; j<=i; j++){ //[j,i], find minimum m and answer is m*(m+1)/2 ll m=INF; for(int k=j;k<=i;k++){ m = min(m, nh[k]); } ans += (m*(m+1))/2LL; ans %= MOD; } } printf("%lld\n", ans); }

Compilation message (stderr)

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
fancyfence.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%lld",&h[i]);
      |         ~~~~~^~~~~~~~~~~~~~
fancyfence.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%lld",&w[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...
#Verdict Execution timeMemoryGrader output
Fetching results...