제출 #24986

#제출 시각아이디문제언어결과실행 시간메모리
24986gabrielsimoesBoat (APIO16_boat)C++14
0 / 100
0 ms17652 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1000000007; const int MAXN = 500; const int MAX = 1e6+10; int n; ll a[MAXN], b[MAXN]; ll dp[MAX], sum[MAX]; int main() { bool test1 = 1, test2 = 1; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld %lld", &a[i], &b[i]); if (a[i] >= MAX || b[i] >= MAX) test2 = 0; if (a[i] != b[i]) test1 = 0; } if (test1) { dp[0] = 1; for (int i = 1; i < n; i++) { dp[i] = dp[i-1] + 1; for (int k = i-1; k >= 0; k--) if (a[k] < a[i]) dp[i] += dp[k]; } printf("%lld\n", dp[n-1]); } else if (test2) { for (int i = 0; i < MAX; i++) sum[i] = 1; for (int i = 0; i < n; i++) { for (int k = b[i]; k >= a[i]; k--) dp[k] = (dp[k] + sum[k-1]) % MOD; for (int i = 1; i < MAX; i++) sum[i] = (sum[i-1] + dp[i]) % MOD; } printf("%lld\n", (sum[MAX-1] - 1 + MOD) % MOD); } }

컴파일 시 표준 에러 (stderr) 메시지

boat.cpp: In function 'int main()':
boat.cpp:16:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
boat.cpp:18:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &a[i], &b[i]);
                                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...