답안 #984819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984819 2024-05-17T06:03:25 Z vjudge1 이상한 기계 (APIO19_strange_device) C++17
0 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>
#define ft first
#define sd second
#define pb push_back
#define nl "\n"
#define int ll
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1000100;

int n, a, b;

void solve() {
    cin >> n >> a >> b;
    int S = 0;
    unordered_map<int, int> mp;
    int R;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        R = r;
        S += (r - l + 1);
        for (int j = l; j <= r; j++) {
            mp[j] = 1;
        }
    }
    if (S <= 1e6) {
        for (auto j : mp) {
            if (j.sd == 0) continue;
            int t = j.ft;
            int k = 0;
            while(t + b * (k + 1) <= R) {
                k++;
                if (mp.find(t + b * k) != mp.end() && (b + 1) * k % a == 0) {
                    S--;
                    mp[t + b * k] = 0;
                }
            }
        }
    }
    cout << S << nl;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    while(T--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 5058 ms 10192 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 768 KB Output is correct
2 Runtime error 518 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 5087 ms 25976 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 307 ms 76064 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 307 ms 76064 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 307 ms 76064 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 750 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 5058 ms 10192 KB Time limit exceeded
3 Halted 0 ms 0 KB -