답안 #1059091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059091 2024-08-14T17:04:06 Z vjudge1 Sirni (COCI17_sirni) C++17
0 / 140
41 ms 2744 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = 1e5 + 3;
const int MX = 1e7 + 3;

bitset<MX> bs;
int n, p[N];
ll ans = 0;

int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #define task "code"
    if (fopen (task".inp", "r")) {
        freopen (task".inp", "r", stdin);
        freopen (task".out", "w", stdout);
    }

    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> p[i];
    sort (p + 1, p + n + 1);
    for (int i = 1, x = 0; i <= n; ++ i) {
        while (bs._Find_next(x) != bs.size() && bs._Find_next(x) <= p[i])
            x = bs._Find_next(x);

        if (i > 1) ans += (p[i] - x);
        for (int j = p[i]; j < MX; j += p[i]) bs[j] = 1;
    }

    cout << ans;

    return 0;
}

Compilation message

sirni.cpp: In function 'int main()':
sirni.cpp:28:66: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |         while (bs._Find_next(x) != bs.size() && bs._Find_next(x) <= p[i])
      |                                                 ~~~~~~~~~~~~~~~~~^~~~~~~
sirni.cpp:20:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sirni.cpp:21:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 2744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 2008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 2656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1880 KB Output isn't correct
2 Halted 0 ms 0 KB -