답안 #30802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
30802 2017-07-26T14:42:46 Z inqr Boat (APIO16_boat) C++14
0 / 100
29 ms 396592 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
#define ll long long
#define pii pair < int , int >
#define DB printf("debug\n");
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define all(x) x.begin() , x.end()
using namespace std;
int n;
ll ans=0,mod=1e9+7;
int a[505],b[505];
void solve1(){
	ll dp[505][100000];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	dp[0][a[0]]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<a[i];j++){//i yi alarak
			dp[i][a[i]]+=dp[i-1][j];
			dp[i][a[i]]%=mod;
		}
		for(int j=0;j<=100000;j++){// i yi almiyarak
			dp[i][j]+=dp[i-1][j];
			dp[i][j]%=mod;
		}
	}
	for(int i=0;i<=100000;i++){
		ans+=dp[n][i];
		ans%=mod;
	}
}
int main(){
	cin.tie(0);ios_base::sync_with_stdio(0);
	//freopen("boat.in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	solve1();
	return 0;
}

Compilation message

boat.cpp: In function 'void solve1()':
boat.cpp:33:15: warning: iteration 100000u invokes undefined behavior [-Waggressive-loop-optimizations]
   ans+=dp[n][i];
               ^
boat.cpp:32:15: note: containing loop
  for(int i=0;i<=100000;i++){
               ^
boat.cpp:28:24: warning: iteration 100000u invokes undefined behavior [-Waggressive-loop-optimizations]
    dp[i][j]+=dp[i-1][j];
                        ^
boat.cpp:27:16: note: containing loop
   for(int j=0;j<=100000;j++){// i yi almiyarak
                ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 396592 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 396592 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 396588 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 396592 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -