題目描述
輸入格式
輸出格式
樣例輸入
4
20 300
40 400
340 700
360 600
樣例輸出
415
#include #include #include #define ll long long
#define int long long
using namespace std;
const int n = 1e5+5;
int n, a[n], w[n], c[n], l = 1<<30, r;
ll s;
bool judge(int x)
return w[n] + c[n] >= x;
}signed main()
printf("%lld\n", l);
return 0;
}
題目描述
輸入格式
輸出格式
樣例輸入
5 6 7
1 2 2 3
2 4 3 3
3 4 2 4
1 3 4 1
4 6 2 1
3 5 2 0
5 4 3 2
樣例輸出
11
#include #include #include #include using namespace std;
const int n = 105, m = 1005, mn = 0x3f3f3f3f;
struct side e[10005];
int head[n], tot;
void add(int x, int y, int z, int w) ;
head[x] = tot;
}int w, n, m, d[n][m], ans = mn;
bool v[n][m];
queue< pair> q;
void spfa(int u) }}
}int main()
spfa(1);
for (int i = 0; i <= w; ++i)
ans = min(ans, d[n][i]);
if (ans == mn) puts("no");
else printf("%d\n", ans);
return 0;
}
code1 : 總時間 258 ms, 記憶體 1268 kib.code2 : 總時間 67 ms, 記憶體 500 kib.
#include #include using namespace std;
const int n = 105;
struct side e[10005];
int head[n], tot;
void add(int x, int y, int z, int w) ;
head[x] = tot;
}int n, m, ans = 1<<30, w;
bool v[n];
void dfs(int x, int s, int d)
for (int i = head[x]; i; i = e[i].next)
}int main()
v[1] = 1;
dfs(1, 0, 0);
if (ans == 1<<30) puts("no");
else printf("%d\n", ans);
return 0;
}
題目描述
輸入格式
輸出格式
樣例輸入
5
6 2 7
5 4 9
1 2 4
2 5 8
1 3 9
52 7 1
2 7 2
3 2 0
5 7 2
4 1 5
樣例輸出
tak
nietak
taknie
#include #include using namespace std;
struct node1 //過載運算子,對物品按a值從小到大排序
}a[1005];
struct node2 /過載運算子,對詢問按m值從小到大排序
}b[1000005];
int n, q, f[100005];//f陣列題解中的加粗部分進行了詳細的解釋
bool ans[1000005];
int main()
for (int i = 1; i <= q; ++i)
puts(ans[i] ? "tak" : "nie");
//三目運算子,個人比較喜歡使用,挺方便
return 0;
}
題目描述
ly星系有很多個星球,有些星球一天有幾十個小時,有些星球一天只有幾個小時。但每個星球的乙個小時都是一樣長的。因此每個星球一天的長短都不一樣,這就導致了乙個問題:星球上的生物都是在白天工作夜晚 休息,因此每個星球每天都有上網高峰期和低峰期,當很多星球同時達到高峰期時,網路便會變得異常擁堵,進而帶來延遲。所以ly星系需要建設乙個有足夠大頻寬的網路來避免這一問題。現在他們想知道,網路在乙個小時內的最大流量是多少。
輸入格式
輸出格式
樣例輸入
2
4 0 1 2 3 4
2 0 3 1
樣例輸出
6
資料範圍與提示
#include #include #define ll long long
using namespace std;
const int n = 30, m = 55440;//1~24中除去13,17,19,23的數的最小公倍數
int n, l[n];
ll a[n][n], ans;
void add(int x)
int main()
for (int j = 0; j < m; ++j)
add(13); add(17); add(19); add(23);
printf("%lld\n", ans);
return 0;
}
Wannafly模擬賽4 題解
a fst是一名可憐的小朋友,他很強,但是經常fst,所以rating一直低迷。但是重點在於,他非常適合acm!並在最近的區域賽中獲得了不錯的成績。拿到獎金後fst決定買一台新筆記本,但是fst發現,在 能承受的範圍內,筆記本的記憶體和速度是不可兼得的。可是,有一些筆記本是被另外一些 完虐 的,也就...
題解 P5594 XR 4 模擬賽
p5594 xr 4 模擬賽 洛谷10月月賽 ii x round 4 div.2前兩道簽到題還是很簡單的,基本上是半小時內一遍過兩題 看看題解,這題stl做法有用set輸出size的和vector unique的,我在打二維陣列 的時候突然發現可以用bitset代替 用二進位制數記錄每天每場比賽有...
模擬賽 circle 題解
題意 有n個數,問有多少個x,x leq t 滿足這n個數分別 x後,異或和為s。每個數小於 2 m 數字dp。由於是加法,需要記錄進製,因此從低位到高位dp。只要記錄下有幾個進製,就可以根據這n的數的大小知道究竟是哪幾個進製了。設 dp i,j,0 1 表示考慮到第i位,有j個進製,與t的大小關係...