답안 #1032076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032076 2024-07-23T10:52:00 Z Gangsta 이상한 기계 (APIO19_strange_device) C++14
0 / 100
5000 ms 524288 KB
#include "bits/stdc++.h"
#define ll long long int
#define pb push_back
#define pii pair<ll,ll>
#define ff first
#define ss second
#define sz size()

const int N = 2e5 + 1;

using namespace std;

ll n, a, b, ans = 0;

set <pii> s;

vector <pii> v;

int main(){
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
    	ll x, y;
    	cin >> x >> y;
    	if(b == 1){
    		if(y - x + 1 >= a) return cout << a,0;
    		ll san = (2*x) % a, san1 = (2*y) % a;
    		if(san <= san1){
    			v.pb({san,0});
    			v.pb({san1,1});
    		} 
    		else{
    			v.pb({0,0});
    			v.pb({san1,1});
    			v.pb({san,0});
    			v.pb({a-1,1});
    		}
    		
    		continue;
    	}
    	for(ll j = x; j <= y; j++){
    		ll san = j + j/b;
    		san %= a;
    		int san1 = j % b;
    		s.insert({san,san1});
    	}
    	ans = (int)s.sz;
    }
    if(b == 1){
    	sort(v.begin(), v.end());
    	ll ac = 0, bas = 1e18;
		for(auto i: v){
			if(i.ss == 0){
				ac++;
				bas = min(bas,i.ff);
			}
			else{
				ac--;
				if(ac == 0){
					ans += i.ff - bas + 1;
					bas = 1e18;
				}
			}
		}
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 34 ms 12680 KB Output is correct
3 Correct 46 ms 18256 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 5 ms 1112 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1705 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 86 ms 32392 KB Output is correct
3 Correct 100 ms 31988 KB Output is correct
4 Correct 72 ms 30672 KB Output is correct
5 Execution timed out 5055 ms 62524 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 942 ms 68724 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 942 ms 68724 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 942 ms 68724 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 905 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 34 ms 12680 KB Output is correct
3 Correct 46 ms 18256 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 5 ms 1112 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -