Submission #791361

# Submission time Handle Problem Language Result Execution time Memory
791361 2023-07-24T03:54:41 Z Amylopectin Fancy Fence (CEOI20_fancyfence) C++14
0 / 100
1 ms 340 KB
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
const long long mxn = 1e3 + 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];
        su += pot(wei[cen+1] - wei[cl]) * (pot(hei[cn]) - pot(chei[cl]));
        su %= mo;
        if(cn > cl)
        {
            chei[cl] = hei[cn];
            enn[cl] = cn-1;
        }
        if(enn[cl] > cn)
        {
            see.insert(cn+1);
            chei[cn+1] = hei[cn];
            enn[cn+1] = cen;
        }
    }
    printf("%lld\n",su);
    return 0;
}

Compilation message

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:29: warning: unused variable 'fn' [-Wunused-variable]
   26 |     long long i,j,n,m,cn,cm,fn,fm,cl,cr,su,cen;
      |                             ^~
fancyfence.cpp:26:32: warning: unused variable 'fm' [-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 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 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 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 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -