QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137513#6626. Real Mountainspenguinman#0 0ms3828kbC++172.4kb2023-08-10 13:39:272024-07-04 01:29:20

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:29:20]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3828kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 13:39:27]
  • 提交

answer

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;

#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define pb emplace_back
#define mp std::make_pair
#define all(a) a.begin(),a.end()
#define mtp std::make_tuple

constexpr ll inf = (1ll<<60);
constexpr ll mod = 1e6+3;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll N; cin >> N;
    vi H(N);
    rep(i,0,N) cin >> H[i];
    vi goal(N,inf);
    ll max = 0;
    rep(i,0,N){
        max = std::max(max, H[i]);
        goal[i] = std::min(goal[i], max);
    }
    max = 0;
    per(i,N-1,0){
        max = std::max(max, H[i]);
        goal[i] = std::min(goal[i], max);
    }
    ll ans = 0;
    rep(i,0,N){
        ans += (goal[i]-1+H[i])*(goal[i]-H[i])/2;
        ans %= mod;
        ans += (goal[i]+1+H[i])*(goal[i]-H[i])/2;
        ans %= mod;
        ans += (goal[i]+1+H[i])*(goal[i]-H[i])/2;
        ans %= mod;
    }
    std::set<ll> set;
    rep(i,0,N){
        ll el = *set.begin();
        if(el > H[i]){
            ans -= (el+1+H[i])*(el-H[i])/2;
            ans %= mod;
            ans += el*(el-H[i]);
            ans %= mod;
        }
        set.insert(H[i]);
    }
    set.clear();
    per(i,N-1,0){
        ll el = *set.begin();
        if(el > H[i]){
            ans -= (el+1+H[i])*(el-H[i])/2;
            ans %= mod;
            ans += el*(el-H[i]);
            ans %= mod;
        }
        set.insert(H[i]);
    }
    {
        std::map<ll,ll> mem;
        rep(i,0,N) mem[H[i]] = mem[goal[i]] = 0;
        ll cnt = 0;
        vi rev;
        for(auto &el: mem){
            el.second = cnt++;
            rev.pb(el.first);
        }
        ll n = cnt;
        vi sum(n);
        rep(i,0,N){
            sum[mem[H[i]]]++;
            sum[mem[goal[i]]]--;
        }
        rep(i,1,n) sum[i] += sum[i-1];
        rep(i,0,n){
            if(sum[i]){
                ans -= (rev[i+1]+1+rev[i])*(rev[i+1]-rev[i])/2;
                ans %= mod;
                ans += rev[i+1]*(rev[i+1]-rev[i]);
                ans %= mod;
            }
        }
    }
    if(ans < 0) ans += mod;
    cout << ans << ln;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3828kb

input:

3
29 9 9

output:

190

result:

wrong answer 1st numbers differ - expected: '0', found: '190'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #3:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

0%