結果

問題 No.54 Happy Hallowe'en
ユーザー chaemonchaemon
提出日時 2014-11-06 22:52:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 3,863 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 84,368 KB
実行使用メモリ 395,084 KB
最終ジャッジ日時 2024-06-10 00:51:29
合計ジャッジ時間 8,196 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 252 ms
394,868 KB
testcase_01 AC 253 ms
394,896 KB
testcase_02 AC 239 ms
394,816 KB
testcase_03 AC 237 ms
394,904 KB
testcase_04 AC 278 ms
394,880 KB
testcase_05 AC 300 ms
394,884 KB
testcase_06 AC 327 ms
395,028 KB
testcase_07 AC 359 ms
394,984 KB
testcase_08 AC 383 ms
395,072 KB
testcase_09 AC 408 ms
395,032 KB
testcase_10 AC 241 ms
394,952 KB
testcase_11 AC 238 ms
395,040 KB
testcase_12 AC 399 ms
395,064 KB
testcase_13 AC 442 ms
395,084 KB
testcase_14 AC 243 ms
394,876 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 247 ms
394,832 KB
testcase_18 AC 239 ms
394,928 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In member function ‘NORMAL_IN& NORMAL_IN::operator>>(std::vector<_Tp>&)’:
main.cpp:102:17: warning: no return statement in function returning non-void [-Wreturn-type]
  102 |                 }
      |                 ^

ソースコード

diff #

// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

//{{{ io
FILE *file_in=stdin,*file_out=stdout;
#define fin normal_in
#define fout normal_out
//const char fname[]="";
//FILE *fin=fopen(fname,"r"),*fout=fopen(fname,"w");
#ifdef __MINGW32__
#define LLD "%I64d"
#define LLU "%I64u"
#else
#define LLD "%lld"
#define LLU "%llu"
#endif
struct NORMAL_IN{
	bool cnt;
	NORMAL_IN():cnt(true){}
	operator int() const {return cnt;}
#define endl "\n"
	NORMAL_IN& operator>>(int &n){cnt=fscanf(file_in,"%d",&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(unsigned int &n){cnt=fscanf(file_in,"%u",&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(long long &n){cnt=fscanf(file_in,LLD,&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(unsigned long long &n){cnt=fscanf(file_in,LLU,&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(double &n){cnt=fscanf(file_in,"%lf",&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(long double &n){cnt=fscanf(file_in,"%Lf",&n)!=EOF;return *this;}
	NORMAL_IN& operator>>(char *c){cnt=fscanf(file_in,"%s",c)!=EOF;return *this;}
	NORMAL_IN& operator>>(string &s){
		s.clear();
		for(bool r=false;;){
			const char c=getchar();
			if(c==EOF){ cnt=false; break;}
			const int t=isspace(c);
			if(!r and !t)r=true;
			if(r){
				if(!t)s.push_back(c);
				else break;
			}
		}
		return *this;
	}
	template<class T>
		NORMAL_IN& operator>>(vector<T> &v){
			int n;fscanf(file_in,"%d",&n);
			REP(i,n){
				T t;*this>>t;
				v.push_back(t);
			}
		}
} normal_in;

struct NORMAL_OUT{
	NORMAL_OUT& operator<<(const int &n){fprintf(file_out,"%d",n);return *this;}
	NORMAL_OUT& operator<<(const unsigned int &n){fprintf(file_out,"%u",n);return *this;}
	NORMAL_OUT& operator<<(const long long &n){fprintf(file_out,LLD,n);return *this;}
	NORMAL_OUT& operator<<(const unsigned long long &n){fprintf(file_out,LLU,n);return *this;}
	NORMAL_OUT& operator<<(const double &n){fprintf(file_out,"%lf",n);return *this;}
	NORMAL_OUT& operator<<(const long double &n){fprintf(file_out,"%Lf",n);return *this;}
	NORMAL_OUT& operator<<(const char c[]){fprintf(file_out,"%s",c);return *this;}
	NORMAL_OUT& operator<<(const string &s){fprintf(file_out,"%s",s.c_str());return *this;}
} normal_out;
//}}}

int N;
int dp[10010][10010];

int main(){
	vector<pii> v;
	fin>>N;
	REP(i,N){
		pii a;
		fin>>a.second>>a.first;
		v.push_back(a);
	}
	sort(ALL(v));
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	int ans = 0;
	REP(i,N){
		for(int j=0;j<10000;j++){
			if(dp[i][j]==0)continue;
			dp[i+1][j]=1;
			if(j<v[i].first){
				int t = j + v[i].second;
				ans = max(ans,t);
				if(t<10000)dp[i+1][t]=1;
			}
		}
	}
	cout<<ans<<endl;
}
0