# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791367 | 2023-07-24T04:01:45 Z | Amylopectin | Fancy Fence (CEOI20_fancyfence) | C++14 | 1 ms | 340 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 264 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 264 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |