| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
watery, use stringstream to process input, still 0ms#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
int main() {
while(1){
string s;
getline(cin, s);
if(s == "ENDOFINPUT") break;
stringstream ss;
ss << s;
string fei;
int gs;
ss >> fei >> gs;
int mn = 2147483647;
vector<int> dur[24];
for(int i = 0; i < gs; i++){
getline(cin, s);
stringstream sss;
sss << s;
int temp;
while(sss >> temp){
dur[i].push_back(temp);
}
}
getline(cin, s);
stringstream ssss;
ssss << s;
int t;
ssss >> t;
getline(cin, s);
for(int i = 0; i < gs; i++){
int offset = 0;
int sz = dur[i].size();
int agg = 0;
while(agg < t){
agg += dur[i][offset];
offset = (offset+1)%sz;
}
int deng = agg - t;
if(deng < mn) mn = deng;
}
cout << mn << endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator