Submission #106653

# Submission time Handle Problem Language Result Execution time Memory
106653 2019-04-19T11:45:51 Z Fasho Preokret (COCI18_preokret) C++14
50 / 50
3 ms 384 KB
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum;

vector<ii> v,bos;

int main()
{
	fast;
	ll x=24*60;
	cin>>n;
	fo(i,1,n)
	{
		ll a;
		cin>>a;
			ii tmp;
			tmp.fi=a;
			tmp.se=1;
		if(a<=x)
		{

			bos.pb(tmp);
		}
		v.pb(tmp);
	}
	cin>>m;
	fo(i,1,m)
	{
		ll a;
		cin>>a;
			ii tmp;
			tmp.fi=a;
			tmp.se=2;
		if(a<=x)
		{
			bos.pb(tmp);
		}
			v.pb(tmp);
	}
	ll a=0;
	
	sort(v.begin(),v.end());
	ll tut=0;
	cout<<bos.size()<<endl;
	fo(i,0,v.size()-1)
	{
		int tmp2=v[i].se;
		if(tmp2==1)
			a--;
		else
			a++;
		if(tut==-1 && a>0)
			sum++;
		if(tut==1 && a<0)
			sum++;
		if(a>0)
			tut=1;
		if(a<0)
			tut=-1;
	}
	cout<<sum;


}

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:17:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fo(i,x,y) for(int i=x;i<=y;i++)
preokret.cpp:62:5:
  fo(i,0,v.size()-1)
     ~~~~~~~~~~~~~~              
preokret.cpp:62:2: note: in expansion of macro 'fo'
  fo(i,0,v.size()-1)
  ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct