Submission #946987

# Submission time Handle Problem Language Result Execution time Memory
946987 2024-03-15T09:26:52 Z biximo Strange Device (APIO19_strange_device) C++17
0 / 100
426 ms 71960 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef array<ll, 2> p2;
int n;
ll A,B;
vector<p2> seq;
bool overs;
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> A >> B;
    seq.resize(n);
    ll tp = A*B;
    overs = (tp/B == A) && (tp/A == B) && tp <= 1e18;
    for(auto&[l,r]: seq) {
    	cin >> l >> r;
    }
    if(overs) {
    	for(int i = 0; i < n; i ++) {
    		auto&[l,r] = seq[i];
    		if(r>=l+A*B-1) {
    			cout << A*B; 
    			return 0;
    		}
    		if(l%(A*B) > r%(A*B)) {
    			seq.push_back({0,r%(A*B)});
    			l %= (A*B);
    			r = A*B-1;
    		} else {
    			l %= A*B;
    			r %= A*B;
    		}
    	}
    }
    sort(seq.begin(),seq.end());
    ll L = -1, R = -2, ans = 0;
    for(auto[l,r]: seq) {
    	if(l <= R+1) {
    		R = max(R, r);
    	} else {
    		ans += R-L+1;
    		L = l;
    		R = r;
    	}
    }
    ans += R-L+1;
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Runtime error 4 ms 1092 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 472 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 356 ms 53272 KB Output is correct
3 Runtime error 269 ms 71960 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 356 ms 53272 KB Output is correct
3 Runtime error 269 ms 71960 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 356 ms 53272 KB Output is correct
3 Runtime error 269 ms 71960 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 37 ms 5592 KB Output is correct
3 Correct 37 ms 5588 KB Output is correct
4 Correct 426 ms 53276 KB Output is correct
5 Correct 39 ms 5864 KB Output is correct
6 Correct 36 ms 5724 KB Output is correct
7 Correct 36 ms 5720 KB Output is correct
8 Correct 39 ms 5716 KB Output is correct
9 Correct 36 ms 5580 KB Output is correct
10 Correct 36 ms 5712 KB Output is correct
11 Correct 37 ms 5724 KB Output is correct
12 Runtime error 30 ms 7476 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Runtime error 4 ms 1092 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -