Submission #126610

# Submission time Handle Problem Language Result Execution time Memory
126610 2019-07-08T07:39:03 Z fjzzq2002 Fortune Telling 2 (JOI14_fortune_telling2) C++14
4 / 100
3000 ms 1528 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 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),ls=0,f=0;
		for(int j=1;j<=k;++j)
		{
			int s=(t[j]>=mx)?2:((t[j]>=mi)?1:0);
			if(!s) continue;
			if(s==2) c^=1;
			else if(s==1&&c!=ls)
				ls=c,f^=1;
		}
		c^=f;
		if(c) ans+=mi; else ans+=mx;
	}
	printf("%lld\n",ans);
}

Compilation message

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:37: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:39: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:41: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 5 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 8 ms 380 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 380 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 5 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 8 ms 380 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 380 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 605 ms 796 KB Output is correct
15 Correct 2321 ms 1340 KB Output is correct
16 Execution timed out 3045 ms 1528 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 8 ms 380 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 380 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 605 ms 796 KB Output is correct
15 Correct 2321 ms 1340 KB Output is correct
16 Execution timed out 3045 ms 1528 KB Time limit exceeded
17 Halted 0 ms 0 KB -