Submission #791367

#TimeUsernameProblemLanguageResultExecution timeMemory
791367AmylopectinFancy Fence (CEOI20_fancyfence)C++14
12 / 100
1 ms340 KiB
#include <stdio.h> #include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; const long long mxn = 1e6 + 10,mo = 1e9 + 7; struct we { long long hhei,idx; }; bool cmp(const struct we &l,const struct we &r) { return l.hhei < r.hhei; } set<long long> see = {}; struct we sot[mxn] = {}; long long hei[mxn] = {},wei[mxn] = {},chei[mxn] = {},enn[mxn] = {}; long long pot(long long l) { long long cn = l * (l+1) / 2; return cn % mo; } int main() { long long i,j,n,m,cn,cm,fn,fm,cl,cr,su,cen; set<long long> :: iterator f; scanf("%lld",&n); for(i=0; i<n; i++) { scanf("%lld",&hei[i]); sot[i] = {hei[i],i}; } for(i=1; i<=n; i++) { scanf("%lld",&wei[i]); wei[i] += wei[i-1]; } sort(sot,sot+n,cmp); see.insert(0); chei[0] = 0; enn[0] = n-1; su = 0; for(i=0; i<n; i++) { cn = sot[i].idx; f = see.upper_bound(cn); cl = (*(prev(f))); cen = enn[cl]; fn = pot(wei[cen+1] - wei[cl]); fm = (pot(hei[cn]) - pot(chei[cl])); su += fn * fm; su %= mo; if(cn > cl) { chei[cl] = hei[cn]; enn[cl] = cn-1; } if(cen > cn) { see.insert(cn+1); chei[cn+1] = hei[cn]; enn[cn+1] = cen; } } printf("%lld\n",su); return 0; }

Compilation message (stderr)

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:26:17: warning: unused variable 'j' [-Wunused-variable]
   26 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,su,cen;
      |                 ^
fancyfence.cpp:26:21: warning: unused variable 'm' [-Wunused-variable]
   26 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,su,cen;
      |                     ^
fancyfence.cpp:26:26: warning: unused variable 'cm' [-Wunused-variable]
   26 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,su,cen;
      |                          ^~
fancyfence.cpp:26:38: warning: unused variable 'cr' [-Wunused-variable]
   26 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,su,cen;
      |                                      ^~
fancyfence.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
fancyfence.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%lld",&hei[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
fancyfence.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%lld",&wei[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...