NA (score:60%) |
NA (score:20%) |
NA (score:60%) |
NA (score:60%) |
NA (score:60%) |
NA (score:90%) |
NA (score:80%) |
以下是我的最後一版:
#include <iostream>
using namespace std;
int a[100000];
int main() {
int n, ans = -9999999;
scanf("%d", &n);
for (int i = 0; i < n; i++){
scanf("%d", &a[i]);
}
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
if (a[i] - a[j] > ans){
ans = a[i] - a[j];
}
}
}
printf("%d", ans);
return 0;
}
我現在的狀況應該是不會錯但測資六以後都會TLE......
希望有大神能救我謝謝
NA (score:60%) NA (score:20%) NA (score:60%) NA (score:60%) NA (score:60%) NA (score:90%) NA (score:80%)
以下是我的最後一版:
#include
using namespace std;
int a[100000];
int main() {
int n, ans = -9999999;
scanf("%d", &n);
for (int i = 0; i < n; i++){
scanf("%d", &a[i]);
}
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
if (a[i] - a[j] > ans){
ans = a[i] - a[j];
}
}
}
printf("%d", ans);
return 0;
}
我現在的狀況應該是不會錯但測資六以後都會TLE......
希望有大神能救我謝謝
Oops...... ChatGPT過了......