您的答案為: GWw`8eu ...略 正確答案為: sw
#include<iostream> #include<string> using namespace std ; struct Video { string s ; int people , length , watchtime , correlation_coefficient ; long long int priority ; }; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int N , i = 0 ; cin >> N ; int times = N ; Video video[100] , temp ; while( N-- ) { cin >> video[i].s >> video[i].people >> video[i].length >> video[i].watchtime >> video[i].correlation_coefficient ; video[i].priority = video[i].people * video[i].watchtime / video[i].length * video[i].correlation_coefficient ; i++ ; } for ( i = 0 ; i < times ; i ++ ) { for ( int j = 0 ; j < times ; j ++ ) { if ( video[i].priority > video[j].priority ) { temp = video[i] ; video[i] = video[j] ; video[j] = temp ; } } } for ( i = 0 ; i < times ; i ++ ) cout << video[i].s << "\n" ; return 0 ; }
#17: 5% WA (line:1)
您的答案為: GWw`8eu ...略 正確答案為: sw
#include #include using namespace std ; struct Video { string s ; int people , length , watchtime , correlation_coefficient ; long long int priority ; }; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int N , i = 0 ; cin >> N ; int times = N ; Video video[100] , temp ; while( N-- ) { cin >> video[i].s >> video[i].people >> video[i].length >> video[i].watchtime >> video[i].correlation_coefficient ; video[i].priority = video[i].people * video[i].watchtime / video[i].length * video[i].correlation_coefficient ; i++ ; } for ( i = 0 ; i < times ; i ++ ) { for ( int j = 0 ; j < times ; j ++ ) { if ( video[i].priority > video[j].priority ) { temp = video[i] ; video[i] = video[j] ; video[j] = temp ; } } } for ( i = 0 ; i < times ; i ++ ) cout << video[i].s << "\n" ; return 0 ; }
video[i].priority 可能為浮點數