답안 #661303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
661303 2022-11-25T12:37:09 Z ktkerem Fancy Fence (CEOI20_fancyfence) C++17
0 / 100
2 ms 384 KB
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
#include<bits/stdc++.h>
/**/
//typedef int ll;
typedef long long ll;
typedef unsigned long long ull;
typedef std::string str;
/*typedef __int128 vll;
typedef unsigned __int128 uvll;*/
#define llll std::pair<ll , ll>
#define pb push_back
#define pf push_front
#define halo cout << "hello\n"
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e9 + 7; 
const ll ous = 1e5 + 7;
const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1};
ll n , m;std::vector<llll> ar;
void solve(){
    ll n;std::cin >> n;
    ar.resize(n+1);
    for(ll i = 0;n>i;i++){
        std::cin >> ar[i].fi;
    }
    for(ll i = 0;n>i;i++){
        std::cin >> ar[i].sec;
    }
    ar[n] = {0 , 0};
    std::vector<llll> v;
    v.pb({0 , 0});
    ll ans = 0;
    for(ll i = 0;n>=i;i++){
        ll ww = 0;
        while(v[(ll)v.size() - 1].fi > ar[i].fi){
            ll nh = std::max(ar[i].fi , v[(ll)v.size() - 2].fi);
            ll df = v[(ll)v.size() - 1].fi - nh;
            ww = (ww + v[(ll)v.size() - 1].sec) % limit;
            v.pop_back();
            //std::cout << df << " " << ww << "\n";
            ans = (ans + (( ((((df * (df+1) / 2) % limit) + ((nh*df) % limit)) % limit) + ((ww * (ww + 1) / 2) % limit) )%limit))%limit;
        }
        v.pb({ar[i].fi , ar[i].sec + ww});
    }
    std::cout << ans << "\n";
    return;/**/
}
signed main(){
    ll t=1;
    //std::cin >> t;
    ll o = 1;
    while(t--){ 
        //cout << "Case " << o++ << ":\n";
        solve();
    }
    return 0;
}/**/

Compilation message

fancyfence.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |                                                                               
fancyfence.cpp: In function 'int main()':
fancyfence.cpp:56:8: warning: unused variable 'o' [-Wunused-variable]
   56 |     ll o = 1;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 2 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -