Submission #1115023


Source Code Expand

#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

ll ns,nc;

void run() {
	scanf("%lld%lld",&ns,&nc);

	// max(x=0..nc/2,min(ns+x,(nc-2*x)/2))

	ll ret=min(ns,nc/2);
	if(2*nc>=ns) {
		ll x=nc/4-ns/2;
		for(ll xx=x-5;xx<=x+5;++xx) {
			if(xx>=0&&2*xx<=nc) {
				//printf("%lld -> %lld\n",xx,min(ns+xx,(nc-2*xx)/2));
				ret=max(ret,min(ns+xx,(nc-2*xx)/2));
			}
		}
	}
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}

Submission Info

Submission Time
Task C - Scc Puzzle
User krijgertje
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1200 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘void run()’:
./Main.cpp:36:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&ns,&nc);
                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 9
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
All 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt AC 1 ms 256 KB
01.txt AC 1 ms 256 KB
02.txt AC 1 ms 256 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 1 ms 256 KB
06.txt AC 1 ms 256 KB
07.txt AC 1 ms 256 KB