Use C ++ to input and output TLE, and use % lld to output WA and % i64d to output
No traps
[Html]
// File Name: hdu4221.cpp
// Author: bo_jwolf
// Created Time: Wednesday, May 08,201 3 PM01: 15: 20 HKT
# Include <vector>
# Include <list>
# Include <map>
# Include <set>
# Include <deque>
# Include <stack>
# Include <queue>
# Include <bitset>
# Include <algorithm>
# Include <functional>
# Include <numeric>
# Include <utility>
# Include <sstream>
# Include <iostream>
# Include <iomanip>
# Include <cstdio>
# Include <cmath>
# Include <cstdlib>
# Include <cstring>
# Include <ctime>
Using namespace std;
Typedef long ll;
Const int maxn = 100005;
Struct node
{
Int a, B;
} Edge [maxn];
Bool cmp (node x, node y)
{
Return x. B <y. B;
}
Int main ()
{
Int t, n;
Int k = 0;
Scanf ("% d", & t );
While (t --)
{
K ++;
Scanf ("% d", & n );
For (int I = 0; I <n; I ++)
Scanf ("% d", & edge [I]. a, & edge [I]. B );
Long sum = 0;
Long ans = 0;
Sort (edge, edge + n, cmp );
For (int I = 0; I <n; I ++)
{
Sum + = edge [I].;
If (sum-edge [I]. B> ans)
Ans = sum-edge [I]. B;
}
Printf ("Case % d: % I64d \ n", k, ans );
}
Return 0;
}
// File Name: hdu4221.cpp
// Author: bo_jwolf
// Created Time: Wednesday, May 08,201 3 PM01: 15: 20 HKT
# Include <vector>
# Include <list>
# Include <map>
# Include <set>
# Include <deque>
# Include <stack>
# Include <queue>
# Include <bitset>
# Include <algorithm>
# Include <functional>
# Include <numeric>
# Include <utility>
# Include <sstream>
# Include <iostream>
# Include <iomanip>
# Include <cstdio>
# Include <cmath>
# Include <cstdlib>
# Include <cstring>
# Include <ctime>
Using namespace std;
Typedef long ll;
Const int maxn = 100005;
Struct node
{
Int a, B;
} Edge [maxn];
Bool cmp (node x, node y)
{
Return x. B <y. B;
}
Int main ()
{
Int t, n;
Int k = 0;
Scanf ("% d", & t );
While (t --)
{
K ++;
Scanf ("% d", & n );
For (int I = 0; I <n; I ++)
Scanf ("% d", & edge [I]. a, & edge [I]. B );
Long sum = 0;
Long ans = 0;
Sort (edge, edge + n, cmp );
For (int I = 0; I <n; I ++)
{
Sum + = edge [I].;
If (sum-edge [I]. B> ans)
Ans = sum-edge [I]. B;
}
Printf ("Case % d: % I64d \ n", k, ans );
}
Return 0;
}