Submission #206583

# Submission time Handle Problem Language Result Execution time Memory
206583 2020-03-04T06:43:13 Z kshitij_sodani Strange Device (APIO19_strange_device) C++17
5 / 100
853 ms 94032 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef int64_t llo;
#define a first
#define  b second
#define endl "\n"
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo n,a,b;
	cin>>n>>a>>b;
	llo x;
	pair<llo,llo> it;
	if((b+1)%a==0){
		x=a;
	}
	else{
		x=a*b;
	}


	llo aa,bb;
	set<pair<llo,llo>> ac;
	for(llo i=0;i<n;i++){
		cin>>aa>>bb;
		aa%=x;
		bb%=x;
		if(bb<aa){
			ac.insert(mp(aa,x-1));
			ac.insert(mp(0,bb));
		}
		else{
			ac.insert(mp(aa,bb));
		}

	}
	vector<pair<llo,llo>> prev;
	for(auto cc:ac){
		if(prev.size()==0){
			prev.pb(cc);
		}
		else{
			if(cc.a>prev.back().b){
				prev.pb(cc);
			}
			else{
				prev[prev.size()-1].b=max(prev[prev.size()-1].b,cc.b);
			}
		}
	}
	llo tot=0;
	for(llo i=0;i<prev.size();i++){
		tot+=prev[i].b-prev[i].a+1;
	}
	cout<<tot<<endl;













	return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:55:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(llo i=0;i<prev.size();i++){
              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 12 ms 1660 KB Output is correct
3 Correct 12 ms 1784 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 632 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 367 ms 5240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 797 ms 94032 KB Output is correct
3 Incorrect 821 ms 94032 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 797 ms 94032 KB Output is correct
3 Incorrect 821 ms 94032 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 797 ms 94032 KB Output is correct
3 Incorrect 821 ms 94032 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 87 ms 12540 KB Output is correct
3 Correct 86 ms 12652 KB Output is correct
4 Correct 841 ms 86248 KB Output is correct
5 Correct 90 ms 12520 KB Output is correct
6 Correct 92 ms 12524 KB Output is correct
7 Correct 85 ms 12524 KB Output is correct
8 Correct 83 ms 12524 KB Output is correct
9 Correct 86 ms 12520 KB Output is correct
10 Correct 82 ms 12520 KB Output is correct
11 Correct 87 ms 12520 KB Output is correct
12 Correct 83 ms 12524 KB Output is correct
13 Correct 85 ms 12524 KB Output is correct
14 Correct 853 ms 86224 KB Output is correct
15 Incorrect 87 ms 12524 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 12 ms 1660 KB Output is correct
3 Correct 12 ms 1784 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -