你們都知道,這題做爲T4仍是未免有的太水了一點。c++
基本思路大概是這樣的:spa
如此循環往復,獲得的即是可行解,因爲獲得的必定在 \(t\) 分鐘裏面,因此 \(t\) 是無用變量。code
代碼:it
#include <bits/stdc++.h> using namespace std; int n,s1,s2,a; //s1,s2分別表明第一和第二個房間 int main(){ scanf("%d",&n);scanf("%d",&n); while(n--){ scanf("%d",&a); printf("%d ",min(s1,s2)); if(s1<s2)s1+=a; else s2+=a; } }