Submission #126632

# Submission time Handle Problem Language Result Execution time Memory
126632 2019-07-08T07:59:41 Z fjzzq2002 Fortune Telling 2 (JOI14_fortune_telling2) C++14
4 / 100
3000 ms 632 KB
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,k,a[SZ],b[SZ],t[SZ];
int ps[SZ],pn;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%d%d",a+i,b+i);
	for(int i=1;i<=k;++i)
		scanf("%d",t+i);
	ll ans=0;
	for(int i=1;i<=n;++i)
	{
		int mi=min(a[i],b[i]),
		mx=max(a[i],b[i]),
		c=(a[i]==mi),f=c;
		pn=0;
		for(int j=1;j<=k;++j)
		{
			int s=(t[j]>=mx)?2:((t[j]>=mi)?1:0);
			if(!s) continue;
			ps[++pn]=s;
		}
		int L=-1,R;
		for(int i=1;i<=pn;++i)
			if(ps[i]==1)
			{
				if(L==-1) L=i;
				R=i;
			}
		if(L==-1)
		{
			for(int i=1;i<=pn;++i)
				if(ps[i]==2) f^=1;
		}
		else
		{
			f=0;
			for(int i=R+1;i<=pn;++i)
				if(ps[i]==2) f^=1;
		}
		if(f) ans+=mi; else ans+=mx;
	}
	printf("%lld\n",ans);
}

Compilation message

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~
fortune_telling2.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",a+i,b+i);
   ~~~~~^~~~~~~~~~~~~~~~
fortune_telling2.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",t+i);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 11 ms 380 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 13 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 11 ms 380 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 13 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 852 ms 504 KB Output is correct
15 Execution timed out 3042 ms 632 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 11 ms 380 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 13 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 852 ms 504 KB Output is correct
15 Execution timed out 3042 ms 632 KB Time limit exceeded
16 Halted 0 ms 0 KB -