답안 #527808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527808 2022-02-18T11:06:01 Z idas Fancy Fence (CEOI20_fancyfence) C++11
15 / 100
28 ms 4420 KB
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr)
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define TSTS int ttt; cin >> ttt; while(ttt--) solve()
#define all(x) (x).begin(), (x).end()
#define le(vec) vec[vec.size()-1]
#define sz(x) ((int)((x).size()))
#define pb push_back
#define s second
#define f first

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;

const int INF=1e9, MOD=1e9+7, mod=998244353;
const ll LINF=1e18;

void setIO()
{
    FAST_IO;
}

void setIO(string s)
{
    FAST_IO;
    freopen((s+".in").c_str(), "r", stdin);
    freopen((s+".out").c_str(), "w", stdout);
}

const int N=1e5+10;
ll h[N], w[N];
int n;

ll eq(ll x)
{
    return (x+1)*x/2%MOD;
}

ll eval(ll x, ll y)
{
    return eq(x)*eq(y)%MOD;
}

bool cmp(int a, int b)
{
    return h[a]<h[b];
}

int main()
{
    setIO();
    cin >> n;
    vi idx; ll wdt=0;
    FOR(i, 0, n) cin >> h[i], idx.pb(i);
    FOR(i, 0, n) cin >> w[i], wdt+=w[i];
    wdt%=MOD;

    sort(all(idx), cmp);

    ll ans=0, lst=0;
    for(auto i : idx){
        ans+=eval(h[i], wdt);
        ans-=eval(lst, wdt);
        ans%=MOD;

        wdt=(wdt+MOD-w[i])%MOD;
        lst=h[i];
    }

    cout << ans;
}

Compilation message

fancyfence.cpp: In function 'void setIO(std::string)':
fancyfence.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fancyfence.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 716 KB Output is correct
3 Correct 13 ms 2384 KB Output is correct
4 Correct 23 ms 4240 KB Output is correct
5 Correct 28 ms 4420 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 716 KB Output is correct
4 Correct 12 ms 2376 KB Output is correct
5 Correct 23 ms 4224 KB Output is correct
6 Correct 27 ms 4420 KB Output is correct
7 Incorrect 1 ms 308 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -