Test instructions: give you a sequence from 0-n initial position of 0, only from I walk to i+1 you need to have the number >= i+1, each location has a[i] individual, ask you how many people you need to go to N.
Problem-Solving ideas: violence
Problem Solving Code:
1 //File name:a.cpp2 //Author:darkdream3 //Created time:2015 April 11 Saturday 23:06 57 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long - - using namespacestd; - intN; - intT; in inttmp; - intMain () { toFreopen ("a-large.in","R", stdin); +Freopen ("Output","W", stdout); -scanf"%d",&t); the for(intCA =1; CA <= t; CA + +) * { $scanf"%d",&n);Panax Notoginseng intsum =0; - intAns =0; the for(intI=0; I <= N;i + +) + { Ascanf"%1d",&tmp); the if(Sum <i) + { -Ans + = i-sum; $sum =i; $ } -Sum + =tmp; - } theprintf"Case #%d:%d\n", Ca,ans); - }Wuyi return 0; the}
View Code
Google Code Jam qualification Round A water