답안 #592108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592108 2022-07-08T13:51:48 Z jasmin Fancy Fence (CEOI20_fancyfence) C++14
27 / 100
35 ms 6396 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int mod=1e9+7;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> h(n);
    map<int,int> ind; int x=1;
    vector<pair<int, vector<int> > >sorted;
    sorted.push_back({0, {}});
    for(int i=0; i<n; i++){
        cin >> h[i];
        if(ind[h[i]]==0){
            sorted.push_back({h[i], {}});
            ind[h[i]]=x;
            x++;
        }
        sorted[ind[h[i]]].second.push_back(i);
    }
    sort(sorted.begin(), sorted.end());
    reverse(sorted.begin(), sorted.end());
    vector<int> w(n);
    for(int i=0; i<n; i++){
        cin >> w[i];
    }

    vector<int> a(n+1);
    int ans=0;
    for(int i=0; i<sorted.size()-1; i++){
        int h=sorted[i].first;
        int next=sorted[i+1].first;

        vector<int> ele=sorted[i].second;
        for(auto e: ele){
            a[e]=w[e];
        
        }

        int s=0; int mom=0;
        for(int j=0; j<=n; j++){
            if(a[j]==0){
                s+=((mom*(mom+1))/2)%mod;
                mom=0;
            }

            mom+=a[j];
            mom%=mod;
        }

        int factor=((h*(h+1))/2 - (next*(next+1))/2)%mod;
        ans+=(s*factor)%mod;
    }

    cout << ans << "\n";
}

Compilation message

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:35:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::vector<long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i=0; i<sorted.size()-1; i++){
      |                  ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 6 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 3 ms 948 KB Output is correct
3 Correct 12 ms 3376 KB Output is correct
4 Correct 22 ms 6248 KB Output is correct
5 Correct 26 ms 6396 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 3 ms 852 KB Output is correct
4 Correct 12 ms 3276 KB Output is correct
5 Correct 21 ms 6256 KB Output is correct
6 Correct 35 ms 6388 KB Output is correct
7 Incorrect 4 ms 468 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 4 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 6 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -