답안 #528266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528266 2022-02-19T18:39:07 Z Olympia Fancy Fence (CEOI20_fancyfence) C++17
30 / 100
1000 ms 2764 KB
#include <cmath>
#include <cassert>
#include <iostream>
#include <set>
#include <climits>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <type_traits>
#include <string>
#include <queue>
#include <map>
#include <stack>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimization ("Ofast")
using namespace std;
const int MOD = 1e9 + 7;
int64_t mult (int64_t x, int64_t y) {
    return (x * y) % MOD;
}
int64_t c2 (int64_t x) {
    return (x * (x + 1)/2) % MOD;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector<int64_t> h(N), w(N);
    vector<pair<int64_t,int64_t>> grid(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> w[i];
    }
    for (int i = 0; i < N; i++) {
        grid[i] = make_pair(w[i], h[i]);
    }
    int64_t ans = 0;
    for (int i = 0; i < N; i++) {
        ans += mult(c2(grid[i].first), c2(grid[i].second));
        ans %= MOD;
        int64_t min_w = grid[i].second;
        for (int j = i + 1; j < N; j++) {
            min_w = min(min_w, grid[j].second);
            ans += mult(c2(min_w), mult(grid[i].first, grid[j].first));
            ans %= MOD;
        }
    }
    cout << ans << '\n';
}

Compilation message

fancyfence.cpp:16: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   16 | #pragma GCC optimization ("O3")
      | 
fancyfence.cpp:17: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   17 | #pragma GCC optimization ("unroll-loops")
      | 
fancyfence.cpp:18: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
   18 | #pragma GCC optimization ("Ofast")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Execution timed out 1072 ms 2376 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 351 ms 716 KB Output is correct
3 Execution timed out 1052 ms 2764 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 373 ms 716 KB Output is correct
4 Execution timed out 1063 ms 2764 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 4 ms 332 KB Output is correct
9 Correct 4 ms 332 KB Output is correct
10 Correct 4 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 324 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 4 ms 332 KB Output is correct
15 Correct 5 ms 324 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 4 ms 320 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 4 ms 320 KB Output is correct
11 Execution timed out 1057 ms 2372 KB Time limit exceeded
12 Halted 0 ms 0 KB -