Submission #900682

# Submission time Handle Problem Language Result Execution time Memory
900682 2024-01-08T21:33:08 Z 3laa Fancy Fence (CEOI20_fancyfence) C++14
15 / 100
57 ms 6600 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
#include <unordered_map>
#define endl '\n'
#define mid ((l+r)/2)
#define  F first
#define  S second
#define pb push_back
#define yes void (cout<<"YES"<<endl)
#define no void (cout<<"NO"<<endl)
#define ump unordered_map <ll,ll>
#define sp " "
#define vll vector<ll>
#define vint vector<int>
#define pll pair<ll,ll>
typedef long long ll;
using namespace std;
const ll inf=1e18+9;
const ll M=1e9+7;
ll n;
ll h[100009];
ll w[100009];
ll suf[100009];
int main(){
    cin>>n;
    for(ll i=0 ; i<n ; i++){
        cin>>h[i];
    }
    ll W=0;
    for(ll i=0 ; i<n ; i++){
        cin>>w[i];
        W+=w[i];
        W%=M;
    }
    suf[n-1]=w[n-1];
    for(ll i=n-2 ; i>=0 ; i--){
        suf[i]=(suf[i+1]+w[i])%M;
    }
    vector<pll> v;
    v.pb({h[0],w[0]});
    for(ll i=1 ; i<n ; i++){
        if(h[i]==h[i-1]){
            v[v.size()-1].S+=w[i];
            v[v.size()-1].S%=M;
        }
        else
            v.pb({h[i],w[i]});
    }
    ll x=((h[0]*(h[0]+1)/2))%M;
    ll y=((W*(W+1))/2)%M;
    ll ans=(x*y)%M;
    for(ll i=1 ; i<v.size() ; i++){
        x=((h[i]*(h[i]+1))/2)%M;
        y=((suf[i]*(suf[i]+1))/2)%M;
        ans=(ans+((x*y)%M))%M;
        x=((h[i-1]*(h[i-1]+1))/2)%M;
        ans=((ans+M)-((x*y)%M))%M;
    }
    cout<<ans<<endl;
}

Compilation message

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:52:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(ll i=1 ; i<v.size() ; i++){
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 2 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 6 ms 2396 KB Output is correct
3 Correct 28 ms 2484 KB Output is correct
4 Correct 55 ms 2740 KB Output is correct
5 Correct 57 ms 2736 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 6 ms 2408 KB Output is correct
4 Correct 34 ms 2652 KB Output is correct
5 Correct 55 ms 2708 KB Output is correct
6 Correct 57 ms 2640 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 6 ms 3032 KB Output is correct
9 Correct 30 ms 4132 KB Output is correct
10 Incorrect 56 ms 6600 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -