错4 7 8 9四个点 求指出错误

P1567 统计天数

@[LxisHz小弟弟](/space/show?uid=56238) ```cpp #include<iostream> using namespace std; int ps[10000000]; int n, to, ans; int main() { ios::sync_with_stdio(false); cin.tie(); cin >> n; if (n == 1) { cout << "1"; return 0; } for (int i = 1; i <= n; i++) { cin >> ps[i]; if (ps[i] > ps[i - 1]) { to++; ans = max(ans, to); } else { to = 1; } } cout << ans << endl; return 0; } ```
by 子寒 @ 2018-08-13 10:13:33


@[子寒](/space/show?uid=121391) ```cpp #include<iostream> using namespace std; int ps[10000000]; int n, to, ans; int main() { ios::sync_with_stdio(false); cin.tie(); cin >> n; if (n == 1) { cout << "1"; return 0; } for (int i = 1; i <= n; i++) { cin >> ps[i]; if (ps[i] > ps[i - 1]) { to++; ans = max(ans, to); } else { to = 1; } } cout << ans << endl; return 0; } ```
by 子寒 @ 2018-08-13 10:14:08


```cpp #include<iostream> using namespace std; int ps[10000000]; int n, to, ans; int main() { ios::sync_with_stdio(false); cin.tie(); cin >> n; if (n == 1) { cout << "1"; return 0; } for (int i = 1; i <= n; i++) { cin >> ps[i]; if (ps[i] > ps[i - 1]) { to++; ans = max(ans, to); } else { to = 1; } } cout << ans << endl; return 0; } ```
by 子寒 @ 2018-08-13 10:14:42


@[LxisHz小弟弟](/space/show?uid=56238) 这个是我的想法,直接在输入中处理数据即可,另外注意cin在处理大数据时的效率问题 ```cpp #include<iostream> using namespace std; int ps[10000000]; int n, to, ans; int main() { ios::sync_with_stdio(false); cin.tie(); cin >> n; if (n == 1) { cout << "1"; return 0; } for (int i = 1; i <= n; i++) { cin >> ps[i]; if (ps[i] > ps[i - 1]) { to++; ans = max(ans, to); } else { to = 1; } } cout << ans << endl; return 0; } ```
by 子寒 @ 2018-08-13 10:17:40


上一页 |